https://github.com/SeleniumHQ/htmlunit-driver
WebDriver compatible driver for HtmlUnit headless browser.
https://github.com/SeleniumHQ/htmlunit-driver
Last synced: about 2 months ago
JSON representation
WebDriver compatible driver for HtmlUnit headless browser.
- Host: GitHub
- URL: https://github.com/SeleniumHQ/htmlunit-driver
- Owner: SeleniumHQ
- License: apache-2.0
- Created: 2016-02-17T08:07:17.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2025-01-23T17:55:42.000Z (3 months ago)
- Last Synced: 2025-02-20T17:06:10.509Z (about 2 months ago)
- Language: Java
- Size: 6.41 MB
- Stars: 258
- Watchers: 45
- Forks: 86
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-java - HtmlUnitDriver
README
# 
**HtmlUnitDriver** is a WebDriver compatible driver for the [HtmlUnit](https://www.htmlunit.org) headless browser.
[](https://maven-badges.herokuapp.com/maven-central/org.seleniumhq.selenium/htmlunit3-driver)
## News
**[Developer Blog](https://htmlunit.github.io/htmlunit-blog/)**
[HtmlUnit@mastodon](https://fosstodon.org/@HtmlUnit) | [HtmlUnit@bsky](https://bsky.app/profile/htmlunit.bsky.social) | [HtmlUnit@Twitter](https://twitter.com/HtmlUnit)
[](https://jenkins.wetator.org/view/HtmlUnit%20Driver/job/HtmlUnitDriver%20-%20Selenium%204/)
## HtmlUnit Remote - Selenium 4 Grid support
Please have a look at the **[HtmlUnit Remote](https://github.com/sbabcoc/htmlunit-remote)** project if you like to use
this driver from [Selenium 4 Grid](https://www.selenium.dev/documentation/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](docs/compatibility.md).### Maven
Simply add a dependency on the latest `htmlunit3-driver` version available in the
[Maven Central](https://repo.maven.apache.org/maven2/org/seleniumhq/selenium/htmlunit3-driver/) repository.Add to your `pom.xml`:
```xml
org.seleniumhq.selenium
htmlunit3-driver
4.29.0```
### Gradle
Add to your `build.gradle`:
```groovy
implementation group: 'org.seleniumhq.selenium', name: 'htmlunit3-driver', version: '4.29.0'
```## Usage
### Simple
You can simply use one of the constructors from the **HtmlUnit** driver class
```java
// simple case - no javascript support
WebDriver webDriver = new HtmlUnitDriver();
``````java
// specify the browser - no javascript support
WebDriver webDriver = new HtmlUnitDriver(BrowserVersion.FIREFOX);
``````java
// simple case - javascript support enabled
WebDriver webDriver = new HtmlUnitDriver(true);
``````java
// 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.```java
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](docs/options.md).
### Selenium compatibility
An overview of the different versions, the **HtmlUnit** version used in each case and the compatibility
can be found in these [tables](docs/compatibility.md).## License
**HtmlUnitDriver** is distributed under Apache License 2.0.