0

I had writen a selenium script for automation, and I am using HTMLUnitDriver for running it on linux as headless browsing. I had some concern -

  • When I try to run my same script with WebDriver, i.e WebDriver driver = new FirefoxDriver() it runs fine successfully.
  • But when I try to run my same script with HTMLUnitDriver, i.e HTMLUnitDriver driver = new HTMLUnitDriver(), I am getting an exception and exception follows:

org.openqa.selenium.TimeoutException: Timed out after 100 seconds waiting for element to be clickable: By.xpath:

I am not getting what will be the root cause for this exception as the same script is running without any issue with firefox or chrome driver, but only it is not working with HTMLUnitDriver. Also I had tried increasing the time but it is also not helpful.

Please can anybody provide any help, will be really appreciated.....Thanks.

haihui
  • 1,075
  • 1
  • 18
  • 25
Rishi Arora
  • 1,713
  • 3
  • 16
  • 31
  • Try enabling JS - `HTMLUnitDriver driver = new HTMLUnitDriver(true)` – JRodDynamite Feb 12 '16 at 05:44
  • I had tried this eanbling the java script then also it is not running, it is showing index out of bound exception - java.lang.IndexOutOfBoundsException: Index: 4, Size: 0 – Rishi Arora Feb 12 '16 at 05:52
  • That seems like a different issue. You'll have to debug your code to find out. Can't do much here without seeing the code. – JRodDynamite Feb 12 '16 at 06:10
  • As an alternative you may try using PhantomJS browser for headless selenium automation. – GKalnytskyi Feb 12 '16 at 06:43
  • I would suggest not using headless drivers at this moment in time. Chrome starts up as fast as headless drivers and with XVFB you don't need a real GUI to run it. The headless drivers right now are using outdated rendering and JavaScript engines and really aren't that representative of real world scenarios. – Ardesco Feb 12 '16 at 09:49
  • To be fair, PhantomJS 2.x is up-to-date. 1.9.x is indeed outdated, while HtmlUnit should probably only be used for very simple pages (but it's very quick). – Andrew Regan Feb 12 '16 at 14:27

1 Answers1

0

Team just a thought - First this seems to be the error - Timed out after 100 seconds waiting for element to be clickable: By.xpath:

That means in Webdriver its enabled and HtmlUnit its disabled ?? .. Am wondering if there is a differences in finding elements in both due to any reasons.

  1. Try this first
    Firefox:: Find element using firefox - check if enabled.

    HTMLUnit:: Since you mentioned its waiting to be clickable and the error is not element not found First find the lement, then next line , display if element is enabled or not.

  2. Also between both of them check if the element is the same element you need. Check properties / text or something.

This will tell you if issue is element itself or its property[enabled/clickable].

Similarly you can also check HTMLUnit driver if some element in same page is findable and clickable.

Makjb lh
  • 432
  • 5
  • 16