MCPcopy Index your code
hub / github.com/HtmlUnit/htmlunit

github.com/HtmlUnit/htmlunit @5.2.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 5.2.0 ↗ · + Follow
55,753 symbols 216,237 edges 5,794 files 36,126 documented · 65% 4 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

HtmlUnit Logo

Version 5.2.0 / June 20, 2026

:heart: Sponsor

Maven Central Version OpenSSF Scorecard

Homepage

htmlunit.org

News

Developer Blog

HtmlUnit@mastodon | HtmlUnit@bsky | HtmlUnit@Twitter

Table of Contents

Overview

HtmlUnit is a "GUI-less browser for Java programs". It models HTML documents and provides an API that allows you to invoke pages, fill out forms, click links, etc... just like you do in your "normal" browser.

It has fairly good JavaScript support (which is constantly improving) and is able to work even with quite complex AJAX libraries, simulating Chrome, Firefox or Edge depending on the configuration used.

HtmlUnit is typically used for testing purposes or to retrieve information from web sites.

Version 5

Starting with version 5.0.0, JDK 17 or higher is required.
If you are still on JDK 8, see Legacy Support (JDK 8) below.

Get it!

Maven

Add to your pom.xml:

<dependency>
    <groupId>org.htmlunit</groupId>
    <artifactId>htmlunit</artifactId>
    <version>5.2.0</version>
</dependency>

Gradle

Add to your build.gradle:

implementation group: 'org.htmlunit', name: 'htmlunit', version: '5.2.0'

Getting Started

You can start here: * Getting Started * Introduction to HtmlUnit - Baeldung * The Java Web Scraping Handbook A nice tutorial about webscraping with a lot of background information and details about HtmlUnit. * Web Scraping Examples how to implement web scraping using HtmlUnit, Selenium or jaunt and compares them. * The Complete Guide to Web Scraping with Java A small straightforward guide to web scraping with Java. * How to test Jakarta Faces with HtmlUnit and Arquillian * WebScraping.AI HtmlUnit FAQ

Features

  • Support for the HTTP and HTTPS protocols
  • Support for cookies
  • Ability to specify whether failing responses from the server should throw exceptions or should be returned as pages of the appropriate type (based on content type)
  • Support for submit methods POST and GET (as well as HEAD, DELETE, ...)
  • Ability to customize the request headers being sent to the server
  • Support for HTML responses
  • Wrapper for HTML pages that provides easy access to all information contained inside them
  • Support for submitting forms
  • Support for clicking links
  • Support for walking the DOM model of the HTML document
  • Proxy server support
  • Support for basic and NTLM authentication
  • Excellent JavaScript support

Selenium Integration

HtmlUnit can be used as a Selenium WebDriver-compatible browser through the htmlunit-driver. This integration allows you to use HtmlUnit as a headless browser option within Selenium test suites, providing fast execution without the overhead of launching a full browser instance.

Please have a look at the HtmlUnit Remote project if you like to use this driver from Selenium 4 Grid.

jsoup Bridge

The htmlunit-jsoup library provides utilities to bridge the gap between HtmlUnit and jsoup. The HtmlUnitDOMToJsoupConverter enables seamless integration between HtmlUnit's comprehensive browser simulation capabilities and all the jsoup-based libraries, allowing you to leverage the full ecosystem of jsoup tools while maintaining HtmlUnit's JavaScript execution and dynamic content handling.

HtmlUnit satellite projects

Built on HtmlUnit

HtmlUnit is used as the underlying "browser" by different Open Source tools like * WebDriver * Arquillian Drone * Serenity BDD * XLT * FluentLenium * WETATOR * Selenium Foundation * Spring Testing * Selenide * JWebUnit * JSFUnit * ...

HtmlUnit is used by many projects for automated web testing * jenkins-test-harness * Apache Shiro * Apache Struts * Quarkus * Togglz * Dataverse * Janssen Project * Apache TomEE * Apache Maven Surefire * JSCover * Apache Jackrabbit * Apache MyFaces * JakartaEE TCK * Jakarta Security * OpenXava * Cargo * piranha cloud * ...

Vulnerabilities

List of Vulnerabilities

Security Policy

Sponsoring

Constantly updating and maintaining the HtmlUnit code base already takes a lot of time.

I would like to make 2 major extensions in the next few months * Add HTTP/2 support * Replace the Rhino based JavaScript engine

For doing this I need your sponsoring.

Contributing

Pull Requests and all other Community Contributions are essential for open source software. Every contribution - from bug reports to feature requests, typos to full new features - are greatly appreciated.

Please try to keep your pull requests small (don't bundle unrelated changes) and try to include test cases.

Legacy Support (JDK 8)

If you need to continue using JDK 8, versions 4.x remain available as-is. Ongoing maintenance and fixes for JDK 8 are only available through sponsorship — please contact me via email to discuss options. Sponsorship provides:

  • Backporting security and bug fixes to the 4.x branch
  • Compatibility maintenance with older Java versions
  • Timely releases for critical issues

Without sponsorship, the 4.x branch will not receive further updates.

Last CI build

The latest builds are available from our Jenkins CI build server

Build Status

Read on if you want to try the latest bleeding-edge snapshot.

Maven

Add the snapshot repository and dependency to your pom.xml:


    <repository>
        <name>Central Portal Snapshots</name>
        <id>central-portal-snapshots</id>
        <url>https://central.sonatype.com/repository/maven-snapshots/</url>
        <releases>
            <enabled>false</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>


    <dependencies>
      <dependency>
          <groupId>org.htmlunit</groupId>
          <artifactId>htmlunit</artifactId>
          <version>5.3.0-SNAPSHOT</version>
      </dependency>

    </dependencies>


Gradle

Add the snapshot repository and dependency to your build.gradle:

repositories {
  maven { url "https://central.sonatype.com/repository/maven-snapshots/" }
  // ...
}
// ...
dependencies {
    implementation group: 'org.htmlunit', name: 'htmlunit', version: '5.3.0-SNAPSHOT'
  // ...
}

License

This project is licensed under the Apache 2.0 License

Development

Checkout these pages on our website for detailed hints about starting with the development: * HtmlUnit Development * Coding Conventions

Some insights

HtmlUnit at openhub

Development Tools

Special thanks to:

JetBrains IntelliJ IDEA
JetBrains for providing IntelliJ IDEA under their open source development license and

Eclipse Foundation
Eclipse Foundation for their Eclipse IDE

SmartGit
to Syntevo for their excellent SmartGit!

Extension points exported contracts — how you extend this code

RefreshHandler (Interface)
A handler for page refreshes. A refresh can be triggered by a response header or a meta tag. @author Mike Bowler @autho [9 …
src/main/java/org/htmlunit/RefreshHandler.java
HtmxConfig (Interface)
(no doc)
src/test/resources/libraries/htmx/htmx-1.7.0/src/htmx.d.ts
WebWindowListener (Interface)
A listener for WebWindowEvent's. This listener informs when a new window is opened, when the content of a window cha [9 …
src/main/java/org/htmlunit/WebWindowListener.java
HtmxExtension (Interface)
(no doc)
src/test/resources/libraries/htmx/htmx-1.7.0/src/htmx.d.ts
WebConnection (Interface)
An object which handles the actual communication portion of page retrieval/submission. @author Mike Bowler @author Dani [8 …
src/main/java/org/htmlunit/WebConnection.java
HtmxConfig (Interface)
(no doc)
src/test/resources/libraries/htmx/htmx-1.9.12/src/htmx.d.ts
JavaScriptErrorListener (Interface)
A listener for JavaScript exceptions. @author Ronald Brill [6 implementers]
src/main/java/org/htmlunit/javascript/JavaScriptErrorListener.java
HtmxExtension (Interface)
(no doc)
src/test/resources/libraries/htmx/htmx-1.9.12/src/htmx.d.ts

Core symbols most depended-on inside this repo

click
called by 9711
src/test/resources/libraries/myfaces/4_0_2/faces.js
push
called by 6142
src/test/resources/libraries/quill/quill.js
on
called by 3692
src/test/resources/libraries/quill/quill.js
replace
called by 3576
src/test/resources/libraries/myfaces/4_0_2/faces.js
add
called by 3290
src/test/resources/libraries/quill/quill.js
get
called by 3083
src/test/resources/libraries/myfaces/4_0_2/faces.js
indexOf
called by 2886
src/test/resources/libraries/quill/quill.js
contains
called by 2422
src/main/java/org/htmlunit/util/geometry/Shape2D.java

Shape

Method 38,789
Function 14,277
Class 2,592
Interface 60
Enum 35

Languages

Java69%
TypeScript30%
Ruby1%
PHP1%
Python1%

Modules by API surface

src/test/java/org/htmlunit/general/HostClassNameTest.java1,060 symbols
src/test/java/org/htmlunit/general/HostTypeOfTest.java1,058 symbols
src/test/java/org/htmlunit/general/DedicatedWorkerGlobalScopeTypeOfTest.java1,057 symbols
src/test/java/org/htmlunit/general/DedicatedWorkerGlobalScopeClassNameTest.java1,057 symbols
src/test/java/org/htmlunit/libraries/jquery/JQuery3x3x1Test.java1,017 symbols
src/test/java/org/htmlunit/libraries/jquery/JQuery1x12x4Test.java862 symbols
src/test/java/org/htmlunit/libraries/jquery/JQuery1x11x3Test.java805 symbols
src/test/java/org/htmlunit/general/huge/ElementClosesElement2Test.java710 symbols
src/test/java/org/htmlunit/libraries/jquery/JQuery1x8x2Test.java662 symbols
src/test/resources/libraries/quill/quill.js589 symbols
src/test/java/org/htmlunit/general/huge/HostParentOfDTest.java530 symbols
src/test/resources/libraries/vue/hello_world/vue.js450 symbols

For agents

$ claude mcp add htmlunit \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact