Without seeing your code, I might hazard a guess that it might be because you need to enable javascript.
JavaScript is disabled by default in the HtmlUnitDriver.
If you look at the source constructor at(LICENSE Apache 2.0)
https://github.com/SeleniumHQ/htmlunit-driver/blob/master/src/main/java/org/openqa/selenium/htmlunit/HtmlUnitDriver.java#L166
/**
* Constructs a new instance, specify JavaScript support
* and using the {@link BrowserVersion#getDefault() default} BrowserVersion.
*
* @param enableJavascript whether to enable JavaScript support or not
*/
public HtmlUnitDriver(boolean enableJavascript) {
this(BrowserVersion.getDefault(), enableJavascript);
}
And the other constructors at https://github.com/SeleniumHQ/htmlunit-driver/blob/master/src/main/java/org/openqa/selenium/htmlunit/HtmlUnitDriver.java#L143-L158
/**
* Constructs a new instance with JavaScript disabled,
* and the {@link BrowserVersion#getDefault() default} BrowserVersion.
*/
public HtmlUnitDriver() {
this(BrowserVersion.getDefault(), false);
}
/**
* Constructs a new instance with the specified {@link BrowserVersion}.
*
* @param version the browser version to use
*/
public HtmlUnitDriver(BrowserVersion version) {
this(version, false);
}
You see that they provide a default false if the variable isn't provided.
So to enable javascript in the HtmlUnitDriver you'll need to provide true when initializing it, that you want JavaScript components active in it.
WebDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_38, true);