I have the following problem.

I have a website where the Login is Via a Link that has the href: SubmitLogin().

I'm trying to use webdriver in the form of PageFactories.

I have this method:

    Reporter.log(String.format("Login with user:%s", username));
    Reporter.log(String.format("Login with password:%s", password));

    //JavascriptExecutor js = (JavascriptExecutor) driver;
    return PageFactory.initElements(driver, AdminHomePage.class);

As you can see I also tried executing the script directly, but it's no good.

The Page isn't doing anything. I have Javascript enabled and I'm using webdriver with HtmlUnitDriver. Like this:

WebDriver webDriver = new HtmlUnitDriver(true);

The true means that Javascript is enabled.

In the log I can't see any problems. The two fields are set correctly, it finds all the necessary elements it just does nothing. :(

In the log I can see a LOT of css warning and a bunch of severe errors stating that some javascripts failed to execute but none mention SubmitLogin. It just seams that doesn't even reach it or whatever. :S

There is no error on the Page.

I want to use HtmlUnitDriver because this will be running on a desktop less build machine.

Additional Information: It's HTTPS. And also, FirefoxDriver with custom profile handles it just fine. I just would like to use HtmlUnitDriver...

Any ideas? :S


  • Could you provide html of "signInLink"
    – Tarun
    Jun 30, 2011 at 17:49
  • Does your build machine run Unix?
    – user246
    Jun 30, 2011 at 19:35
  • Sorry that I can answer only now. So... It's a windows machine. And It seems that Javascript is causing the trouble because the page gets loaded. So https couldn't be the cause. I reverted to firefoxdriver for now. :(
    – Hannibal
    Jul 1, 2011 at 5:35

2 Answers 2


If you are only using HtmlUnitDriver because you don't have a screen, just run the test with the firefox driver and run it headless. In case you are not familiar with headless it is as simple as running Xvfb :1 -ac -screen 0 1024x768x24; export DISPLAY=:1 We use headless firefox selenium tests on a hudson server that doesnt have a screen. Works fine for us

  • It's a windows box actually. Yeah I know of headless running, could your elaborate? Thanks!
    – Hannibal
    Jul 1, 2011 at 5:34
  • I am actually not sure you can run headless Firefox on a Windows box, but if you could it would be your best bet.
    – Jason Ward
    Jul 1, 2011 at 12:47

I appreciate the value of being able to run tests on a machine that does not have a desktop. However, I have never been successful at getting a test that works with a real browser to also work with HtmlUnitDriver. I would be reluctant to draw any conclusions about the quality of a web application based on the results of running an HtmlUnitDriver-based test.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.