beingKrishna
beingKrishna

Reputation: 78

HtmlUnitDriver fails to load url.

I am currently using HtmlUnitDriver 2.45 version and when I run below code snippet

 BrowserVersion version = BrowserVersion.CHROME;
    WebDriver driver = new HtmlUnitDriver(version);
    driver.get("http://www.google.com");
    System.out.println(driver.getCurrentUrl());

my output is "about:blank".

I have noticed that driver instance created from default constructor

WebDriver driver = new HtmlUnitDriver(true);

creates driver object with deprecated default browser version "INTERNET_EXPLORER_8"

/** The default browser version. */
private static BrowserVersion DefaultBrowserVersion_ = INTERNET_EXPLORER_8;

Am I missing something while creating HtmlUnitDriver??

Upvotes: 0

Views: 538

Answers (1)

aholt
aholt

Reputation: 2981

My experience with HTMLUnitDriver has been pretty terrible so far. It doesn't really serve as a viable testing driver due to the multiple compatibility issues it has with different applications (depends on the application).

If you are trying to do headless browser testing, I would suggest running PhantomJSDriver rather than HTMLUnitDriver. In your use-case this should be fine, since you are trying to run HTMLUnitDriver as the CHROME browser version, and PhantomJS is webkit-based.

Upvotes: 1

Related Questions