Git Product home page Git Product 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

Maven/Gradle/...

Add a dependency on the latest htmlunit-driver version available in the Maven Central, please note that both artifactId and version are changed to match the dependent HtmlUnit version:

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>htmlunit-driver</artifactId>
    <version>2.46.0</version>
</dependency>

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.

htmlunit-driver's People

Contributors

asashour avatar rbri avatar barancev avatar lukeis avatar shs96c avatar glibas avatar rjimgal avatar rwinch avatar simple-elf avatar asolntsev avatar jneira avatar dependabot[bot] avatar

Watchers

James Cloos avatar

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.