HtmlUnit
Initial releaseMay 22, 2002 (2002-05-22)
Stable release
4.21.0 / December 28, 2025; 5 months ago (2025-12-28)
Written inJava
Operating systemCross-platform (JVM)
Available inEnglish
TypeWeb browser
LicenseApache License 2.0
Websitehttps://www.htmlunit.org/
Repository

HtmlUnit is a headless web browser written in Java. It allows high-level manipulation of websites from other Java code, including filling and submitting forms and clicking hyperlinks. It also provides access to the structure and the details within received web pages. HtmlUnit emulates parts of browser behaviour including the lower-level aspects of TCP/IP and HTTP. A sequence such as getPage(url), getLinkWith("Click here"), click() allows a user to navigate through hypertext and obtain web pages that include HTML, JavaScript, Ajax and cookies. This headless browser can deal with HTTPS security, basic HTTP authentication, automatic page redirection and other HTTP headers. It allows Java test code to examine returned pages either as text, an XML DOM, or as collections of forms, tables, and links.[1]

The goal is to simulate real browsers; namely Chrome, Firefox and Edge.

The most common use of HtmlUnit is test automation of web pages, but sometimes it can be used for web scraping, or downloading website content.

Benefits

edit
  • Provides high-level API, taking away lower-level details away from the user.[2]
  • Compared to other WebDriver implementations, HtmlUnitDriver is the fastest to implement.[3]
  • It can be configured to simulate a specific browser.

Drawbacks

edit
  • Element layout and rendering can not be tested.[4]
  • The JavaScript support is not complete, which is one of the areas of ongoing enhancements.

Used technologies

edit

Libraries using HtmlUnit

edit

See also

edit

References

edit
  1. ^ "HtmlUnit Home". Sourceforge. Retrieved 30 August 2019.
  2. ^ Beust, Cédric; Suleiman, Hani (15 October 2007). Next Generation Java Testing: TestNG and Advanced Concepts. Pearson Education. ISBN 9780132702270. Retrieved 30 August 2019.
  3. ^ "HtmlUnit Driver". Github. Retrieved 30 August 2019.
  4. ^ "Testing HTML Unit". GWT Project. Retrieved 30 August 2019.

Bibliography

edit

Further reading

edit
edit

📚 Artikel Terkait di Wikipedia

Headless browser

correctly interpret many popular websites. Another is HtmlUnit, a headless browser written in Java. HtmlUnit uses the Rhino engine to provide JavaScript and

Comparison of HTML parsers

htacg/tidy-html5". GitHub. "HTML Tidy". www.html-tidy.org. "Release HtmlUnit 3.7.0 · HtmlUnit/htmlunit". GitHub. "Index of /software/BeautifulSoup/bs4/download/4

Selenium (software)

Microsoft Edge); there is also an HtmlUnit browser driver, which simulates a browser using the headless browser HtmlUnit. Since Selenium 4 and Google Chrome

HttpUnit

testing. Software performance testing Performance Engineering Software HtmlUnit "HttpUnit". VA Technical Reference Model v 23.2. November 25, 2013. Retrieved

Capybara (software)

Acceptance test-driven development Behavior-driven development Test automation HtmlUnit List of web testing tools Regression testing Given-When-Then "Release 3

List of unit testing frameworks

barnett.id.au. Archived from the original on March 4, 2007. Bowler, Mike. "HtmlUnit". sourceforge.net. "ieunit - Unit test framework for web pages". Google