Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

Advantages of HtmlUnitDriver are:

Category: Selenium WebDriver

WebDriver driver = new HtmlUnitDriver()

Fastest implementation of WebDriver compared to other browsers
A pure Java solution and so it is platform independent.
Supports JavaScript
It allows you to choose other browser versions to run your scripts.

JavaScript In HtmlUnit Driver:

HtmlUnitDriver uses Rhino JavaScript engine. Other browsers are using separate JavaScript engine. So the test results may differ when compared to other browsers when you test JavaScript applications using HtmlUnit. By default, JavaScript is disabled in HtmlUnitDriver. Don’t worry, there is a way to enable it.
Enabling JavaScript while initializing the HtmlUnitDriver:
HtmlUnitDriver driver = new HtmlUnitDriver(true);

Setting ‘setJavascriptEnabled’ to true
HtmlUnitDriver driver = new HtmlUnitDriver();
setJavascriptEnabled(true);

Leave a Reply

Your email address will not be published. Required fields are marked *