Jump to content

HtmlUnit

From Alfawiki
Adapted from the English Wikipedia article HtmlUnit, available under CC BY-SA 4.0Updated 9 August 2025
HtmlUnit
Company typeSoftware library
IndustrySoftware development, Web testing
ProductsHeadless web browser for Java
Websitehtmlunit.sourceforge.io

HtmlUnit is a headless web browser developed in Java that facilitates advanced interaction with websites through Java programming. It supports operations such as completing and submitting forms and activating hyperlinks. This tool grants access to the underlying web page architecture and content, replicating browser functionalities including TCP/IP communication and HTTP protocols. Users can navigate hypertext using commands like getPage(url), getLinkWith("Click here"), and click(). HtmlUnit processes HTML, JavaScript, Ajax, and manages cookies, while offering features like HTTPS encryption, basic HTTP authentication, automatic redirects, and customizable HTTP headers. Java-based test scripts can analyze the retrieved pages in formats such as plain text, XML DOM, or structured collections of forms, tables, and links.

The software is designed to mimic popular browsers including Chrome, Firefox, and Edge.

Although mainly utilized for test automation of web applications, HtmlUnit is also employed for tasks like web scraping and downloading website content.

Benefits

  • Provides a high-level API that abstracts complex underlying processes.
  • HtmlUnitDriver ranks among the quickest WebDriver implementations available.
  • Allows configuration to emulate specific browser environments.

Drawbacks

  • Lacks capabilities for testing visual element layout and rendering.
  • JavaScript support remains partial but is continuously being enhanced.

Used technologies

Libraries using HtmlUnit

See also

Bibliography

  • pp. 339–

Further reading

External links