Version 4.41.0 / February 22, 2026
HtmlUnitDriver is a WebDriver compatible driver for the HtmlUnit headless browser.
❤️ Sponsor
News
HtmlUnit@mastodon | HtmlUnit@bsky | HtmlUnit@Twitter
HtmlUnit Remote - Selenium 4 Grid support
Please have a look at the HtmlUnit Remote project if you like to use this driver from Selenium 4 Grid.
Get it!
An overview of the different versions, the HtmlUnit version used in each case and the compatibility can be found in these tables.
Maven
Simply add a dependency on the latest htmlunit3-driver version available in the
Maven Central repository.
Add to your pom.xml:
<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>htmlunit3-driver</artifactId> <version>4.41.0</version> </dependency>
Gradle
Add to your build.gradle:
implementation group: 'org.seleniumhq.selenium', name: 'htmlunit3-driver', version: '4.41.0'
Usage
Simple
You can simply use one of the constructors from the HtmlUnit driver class
// simple case - no javascript support WebDriver webDriver = new HtmlUnitDriver();
// specify the browser - no javascript support WebDriver webDriver = new HtmlUnitDriver(BrowserVersion.FIREFOX);
// simple case - javascript support enabled WebDriver webDriver = new HtmlUnitDriver(true);
// specify the browser - javascript support enabled WebDriver webDriver = new HtmlUnitDriver(BrowserVersion.FIREFOX, true);
Customization
HtmlUnit offers many customization options. Similar to the other WebDriver implementations, the HtmlUnitDriverOptions class can be used to customize your HtmlUnit driver.
final HtmlUnitDriverOptions driverOptions = new HtmlUnitDriverOptions(BrowserVersion.FIREFOX); // configure e.g. driverOptions.setCapability(HtmlUnitOption.optThrowExceptionOnScriptError, false); HtmlUnitDriver webDriver = new HtmlUnitDriver(driverOptions); // use the driver
NOTE: Complete details for the HtmlUnitDriverOptions class can be found here.
Selenium compatibility
An overview of the different versions, the HtmlUnit version used in each case and the compatibility can be found in these tables.
License
HtmlUnitDriver is distributed under Apache License 2.0.
Development Tools
Special thanks to:
JetBrains for providing IntelliJ IDEA under their open source development license and
