Coder Social home page Coder Social logo

htmlunit-driver's Introduction

HtmlUnitDriver

HtmlUnitDriver is a WebDriver compatible driver for the HtmlUnit headless browser.

Maven Central

News

Twitter

Build Status

Download and Installation

There are two versions available

Selenium compatibility

Starting with Selenium 4.5 we use the same version numbers for the driver - e.g. HtmlUnit-Driver 4.10.0 is for Selenium 4.10.0.

Because there are so many tools working on top HtmlUnitDriver, we now maintain two version (artifact id's).

htmlunit3-driver uses the (latest) version of HtmlUnit 3.x and is therefore not backward compatible.

htmlunit-driver is backward compatible but it still is based on HtmlUnit 2.70.

For an overview please check the following tables:

htmlunit3-driver

selenium htmlunit-driver htmlunit artifactId
4.10.0 4.10.0 3.3.0 htmlunit3-driver
4.9.1 4.9.1 3.2.0 htmlunit3-driver
4.9.0 4.9.0 3.1.0 htmlunit3-driver
4.8.3 4.8.3 3.1.0 htmlunit3-driver
4.8.1 4.8.1 3.0.0 htmlunit3-driver

htmlunit-driver

selenium htmlunit-driver htmlunit artifactId
4.10.0 4.10.0 2.70.0 htmlunit-driver
4.9.1 4.9.1 2.70.0 htmlunit-driver
4.9.0 4.9.0 2.70.0 htmlunit-driver
4.8.3 4.8.3 2.70.0 htmlunit-driver
4.8.1 4.8.1.1 2.70.0 htmlunit-driver
4.8.1 4.8.1 3.0.0 htmlunit-driver
4.8.0 4.8.0 2.70.0 htmlunit-driver
4.7.2 4.7.2 2.67.0 htmlunit-driver
4.7.0 4.7.0 2.67.0 htmlunit-driver
4.6.0 4.6.0 2.66.0 htmlunit-driver
4.5.2 4.5.2 2.66.0 htmlunit-driver
4.5.0 4.5.0 2.65.1 htmlunit-driver
4.4.0 3.64.0 2.64.0 htmlunit-driver
4.3.0 3.63.0 2.63.0 htmlunit-driver
4.2.1 3.62.0 2.62.0 htmlunit-driver
4.1.3 3.61.0 2.61.0 htmlunit-driver
4.1.0 3.56.0 - 3.60.0 2.56.0 - 2.60.0 htmlunit-driver
4.0.0 3.55.0 3.55.0 htmlunit-driver
3.141.59 2.70.0 2.70.0 htmlunit-driver
3.141.59 2.67.0 2.67.0 htmlunit-driver
3.141.59 2.66.0 2.66.0 htmlunit-driver
3.141.59 2.65.0 2.65.1 htmlunit-driver
3.141.59 2.64.0 2.64.0 htmlunit-driver
3.141.59 2.63.0 2.63.0 htmlunit-driver
3.141.59 2.62.0 2.62.0 htmlunit-driver
3.141.59 2.61.0 2.61.0 htmlunit-driver
3.141.59 2.60.0 2.60.0 htmlunit-driver

Maven/Gradle/...

Simply add a dependency on the latest htmlunit3-driver version available in the Maven Central.

Add to your pom.xml:

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>htmlunit3-driver</artifactId>
    <version>4.10.0</version>
</dependency>

Add to your build.gradle:

implementation group: 'org.seleniumhq.selenium', name: 'htmlunit3-driver', version: '4.10.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);

More customization

HtmlUnit offers a lot more customization options. To adjust these options you can use this pattern.

WebDriver webDriver = new HtmlUnitDriver(BrowserVersion.FIREFOX, true) {
    @Override
    protected WebClient modifyWebClient(WebClient client) {
        final WebClient webClient = super.modifyWebClient(client);
        // you might customize the client here
        webClient.getOptions().setCssEnabled(false);

       return webClient;
    }
};

And for some special cases you and also overwrite the method newWebClient(final BrowserVersion version) to adjust the webClient before the standard WebDriver setup takes place or for constructing your own webClient.

License

HtmlUnitDriver is distributed under Apache License 2.0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.