• What is Automation Testing - Advantages & Types of Tools
  • What is Selenium IDE, Selenium RC, Selenium WebDriver, Selenium Grid?
  • Selenium IDE, Firebug & Firepath Installation


  • Selenium WebDriver Architecture
  • Selenium Installation
  • Challenges and Limitations of Selenium
  • First Selenium WebDriver Script
  • Working with Firefox Browser
  • Solution - Failed To Launch Browser Using Selenium WebDriver
  • Working with Chrome Browser
  • Working with IE Browser
  • Difference Between FindElement & FindElements
  • Install Firebug, Fire path and other add on for Selenium
  • Locators in Selenium
  • Dynamic Xpath
  • Dynamic CSS
  • Handle drop-downs
  • How to work with file upload
  • Handle Alerts & Popups
  • Handle Multiple Windows
  • Mouse Hover event in Selenium
  • Right Click
  • Double Click
  • Drag and Drop
  • Capture Screenshots in Selenium
  • Parameterization
  • Synchronization
  • Implicit Wait, Explicit Wait and Fluent Wait in Selenium
  • Implicit Waits
  • Explicit WebDriver Waits
  • Fluent Wait In Selenium
  • Apache POI
  • How To Read Data From Excel File
  • How To Write Data In Excel File
  • Database Testing Using MSSQL
  • Database Testing Using MySQL
  • Database Testing Using DB2
  • Handle Ajax Call in Selenium
  • Listeners in Selenium
  • Handling JavaScript in Selenium
  • Stale Element Reference Exception in Selenium
  • Integrate Sikuli with Selenium
  • Headless Browser Testing 
  • Headless Browser Testing using HtmlUnitDriver
  • Headless Browser Testing using PhanthomJSDriver


  • TestNG Installation
  • TestNG Complete Tutorial


  • Extent Reports Introduction
  • Extent Reports Generation
  • Capturing Screenshots & Including In Extent Reports
  • Extent Reports Version 4


  • ANT Build Tool - How To Download & Install
  • Maven Build Tool - How To Download & Install
  • Creating Maven Selenium Project
  • GIT Integration with Selenium
  • Jenkins - How To Download & Install
  • Jenkins - Executing TestNG Scripts
  • Jenkins - Generating Reports After Test Execution
  • Jenkins - Executing Maven Project
  • Create build and Execute build for nightly execution
  • Send Email report based on build Status
  • Selenium Continuous Integration with Jenkins [Selenium – Maven – Git – Jenkins] – Step By Step Guide


  • Running Selenium Tests On BrowserStack
  • Kobiton - Mobile Testing Platform with Real Devices


  • Mobile Testing Platform with Real Devices


  • What is Framework & Types of Framework
  • Page Object Model Design Pattern
  • Data Driven Framework
  • How to explain Test Automation Framework or Selenium Automation Framework Architecture In Interview

  • API Testing:

  • Learn API Testing
  • Postman Tutorial (API Testing with Postman)


  • Test Automation Framework Interview Questions
  • Selenium Interview Questions
  • TestNG Interview Questions
  • Java Interview Questions
  • Python Interview Questions
  • API Testing Interview Questions


  • Automation Tester Resume
  • Headless Browser Testing Using HtmlUnitDriver in Selenium WebDriver

    Headless Browser Testing Using HtmlUnitDriver In Selenium WebDriver

    In the earlier post, we have given a brief explanation on what is headless browser and in this post, we learn how to perform headless browser testing using HtmlUnitDriver in Selenium WebDriver. HtmlUnitDriver is one of the drivers of Selenium WebDriver. HtmlUnitDriver and PhatomJsDriver are most popular headless browsers.

    Headless Browser Testing using Selenium WebDriver

    You could download HtmlUnitDriver Jar file from here. – Selenium HtmlUnit Driver

    Html Unit Driver is currently the fastest and most lightweight implementation of WebDriver. As the name suggests, this is based on HtmlUnit. HtmlUnit is a java based implementation of a web browser without a GUI. HtmlUnit Driver is a well known Headless Browser driver. HtmlUnit Driver is similar to the other drivers such as Mozilla Firefox, Google Chrome, Internet Explorer but you couldn’t see the GUI of Html UnitDriver.

    You can create a HtmlUnitWebDriver as shown below

    Advantages of HtmlUnitDriver are:

    • 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.

    Usually, to run Selenium Scripts using Firefox, we initialize the Firefox driver.

    Whereas while running Selenium Scripts using HtmlUnitDriver you need to write the below statement

    Remaining statements in your script will be as usual.

    Let’s see a working example on HtmlUnitDriver in Selenium WebDriver.


    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. J

    It’s very easy to enable JavaScript support. We could enable JavaScript in HtmlUnitDriver in two ways

    1. Enabling JavaScript while initializing the HtmlUnitDriver

    2. Setting ‘setJavascriptEnabled’ to true

    None of the popular browsers use the JavaScript engine used by HtmlUnit (Rhino). If you test JavaScript using HtmlUnit the results may differ significantly from those browsers.

    Different Browser Versions using HtmlUnitDriver:

    We could test our scripts on different browser versions using HtmlUnitDriver. Yes, it allows us to choose our preferred browser version. See the below screenshot.

    I am concluding this post about headless browser testing using HtmlUnitDriver. In the next post, we will learn how to perform headless browser testing using PhanthomJSDriver in Selenium WebDriver.

    As always, feel free to share this post with your friends and colleagues on Facebook, Twitter, and Google Plus!

    Headless browser testing using HtmlUnitDriver

    Get our latest blog posts delivered to your inbox

    Subscribe and get popular blog posts about software testing industry.


    3 thoughts on “Headless Browser Testing Using HtmlUnitDriver in Selenium WebDriver”

    1. It’s better you also specify full flag dependency like which Selenium version needs to be used.

      • Hi Nimesh, thanks. Will try to do for the new posts.

    2. Here are the Version of different libraries to run htmlunitDriver-






    Leave a Comment

    Share via
    Copy link
    Powered by Social Snap