Wednesday, 2 October 2013

HtmlUnitDriver does not appear to be loading page

HtmlUnitDriver does not appear to be loading page

I'm trying to get HtmlUnitDriver to work in my development environment. As
a beginner, I've tried implementing the example from the following page
using the latest selenium server jar:
http://code.google.com/p/selenium/wiki/GettingStarted
Unfortunately, whenever I try to run this program, I get the following
exception:
Exception in thread "main" org.openqa.selenium.NoSuchElementException:
Unable to locate element with name: q
For documentation on this error, please visit:
http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.35.0', revision: 'c916b9d', time: '2013-08-12
15:42:01'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1',
java.version: '1.6.0_16'
Driver info: driver.version: HtmlUnitDriver
at
org.openqa.selenium.htmlunit.HtmlUnitDriver.findElementByName(HtmlUnitDriver.java:853)
at org.openqa.selenium.By$ByName.findElement(By.java:292)
at
org.openqa.selenium.htmlunit.HtmlUnitDriver$5.call(HtmlUnitDriver.java:1404)
at
org.openqa.selenium.htmlunit.HtmlUnitDriver$5.call(HtmlUnitDriver.java:1)
at
org.openqa.selenium.htmlunit.HtmlUnitDriver.implicitlyWaitFor(HtmlUnitDriver.java:1094)
at
org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:1401)
at
org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:419)
at Justin.Main.main(Main.java:30)
I've tried modifying my code to incorporate the fixes implemented here:
HtmlUnitDriver causes problems while getting an url
I've tried getting the URL of the page using driver.getCurrentUrl() after
the call to driver.get("http://www.google.com"), but the string that is
returned is about:blank.
Similar code in this example would definitely work if I were to run it
using FirefoxDriver, but to meet requirements, I need my script to run
headless with selenium.
Any help would be greatly appreciated.

No comments:

Post a Comment