Friday, 8 November 2013

HTMLUnitDriver Extra cover

HTMLUnitDriver is the fastest implementation of WebDriver. It is a java based implementation of a Web Browser without a GUI. For any language binding (other than java) the Selenium Server is required to use this driver. It supports JavaScript. JavaScript engine used by the HTMLUnit (Rhino) is different from other popular browsers. Testing JavaScript using HTMLUnit differ significantly with results.

Download the latest Selenium drivers[2.35 or above];  Older versions of Selenium won't work.

Handle Transparent Proxy 

HtmlUnitDriver driver = new HtmlUnitDriver();    
driver.setProxy("", port);    //  set proxy for handling Transparent Proxy
driver.setJavascriptEnabled(true);    //  enable JavaScript [this emulate IE's js by default]

Emulate popular Browser's JS

HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_17);

Emulate specific Browser's JS using Capabilities

DesiredCapabilities capabilities = DesiredCapabilities.htmlUnit();
driver = new HtmlUnitDriver(capabilities);
DesiredCapabilities capabilities = DesiredCapabilities.firefox();  
capabilities.setBrowserName("Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0");
driver = new HtmlUnitDriver(capabilities); 


  1. Thanks for the great information in your blog Selenium Training in Chennai

  2. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about SAP BASIS.SAP basis

  3. It was very nice blog to learn about SAP BASIS. Thanks for sharing.SAP basis

  4. Best place to learn Appium Android IOS Automation Testing Training in Chennai

    Go for Appium training in chennai for real time mobile automation testing training with real time project support.
    UI Automation Tools with real time scenarios You can contact 8122241286 for Best APPIUM and selenium Training in Chennai

  5. Can't we capture screenshots using HTMLunit driver as that of PhantomJs.
    HTMLunitdriver screenshots throws some cast exception.