HtmlUnit
| Company type | Software library |
|---|---|
| Industry | Software development, Web testing |
| Products | Headless web browser for Java |
| Website | htmlunit |
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
- W3C DOM
- HTTP connectivity through Apache HttpComponents
- JavaScript execution via a customized version of Rhino
- HTML parsing powered by NekoHTML
- CSS processing using CSS Parser
- XPath functionality provided by Xalan
Libraries using HtmlUnit
- Selenium WebDriver
- Spring MVC Test Framework
- Testing tools within Google Web Toolkit [1]
- WebTest
- Wetator
See also
Bibliography
- pp. 339–
Further reading
- Langer, A. "Extending HtmlUnit for test automatisation of Web applications using AJAX"; Betreuer/in (nen): T. Grechenig, M. Bernhart; 183/1, 2009.