HtmlUnitDriver does not appear to be loading page HtmlUnitDriver does not appear to be loading page selenium selenium

HtmlUnitDriver does not appear to be loading page


In the example code given, it assumes the older Google page exists which has the search field with name=q.

The page no longer is labelled that way - try changing driver.findElement(By.name("q")) to driver.findElement(By.cssSelector("input[id=gbqfq]") and see if that fixes your issue - at the very least it should be able to input to the search bar once you get the page loaded up.

If you called driver.getCurrentUrl() immediately after trying to get the page, it may not have loaded completely and instead returned about:blank.

If that doesn't work, we can keep troubleshooting - it's harder to see what's actually happening with a headless browser, so you may want to switch to a FirefoxDriver temporarily to visualize exactly what's happening.


Ill try to give it a shot:

If it is a network problem, please download this tool to check if the port your are connecting to is in use:http://technet.microsoft.com/en-us/sysinternals/bb897437.aspx

Very handy for these kind of situations.

For further debugging, try reading out the source.Put this line before the first element selector and after the page loaded.:

System.out.println(driver.getPageSource());

I wonder if the element is there..


Try using the Selenium IDE plugin with Firefox to see what it scrapes when it does it actions. You can export the code into java and then try to run that also. I would also step through the code on the both home and work computer to see if there are any differences. I have seen code work (when that element not found error happens) when being stepped through due to the DOM having time to fully load. Furthermore, try to instantiate and actual browser so you can visuallly see whats happening.

Also, verify version of all software your using between home and workstation.