0% found this document useful (0 votes)
13 views3 pages

HtmlUnit: Java Headless Browser Guide

HtmlUnit is a headless web browser written in Java that allows high-level manipulation of websites from Java code through filling forms, clicking links, and accessing page structure and details. It emulates browser behavior like TCP/IP, HTTP, and supports technologies like JavaScript, Ajax, and cookies. HtmlUnit is commonly used for web page test automation but can also be used for web scraping.

Uploaded by

linda976
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

HtmlUnit: Java Headless Browser Guide

HtmlUnit is a headless web browser written in Java that allows high-level manipulation of websites from Java code through filling forms, clicking links, and accessing page structure and details. It emulates browser behavior like TCP/IP, HTTP, and supports technologies like JavaScript, Ajax, and cookies. HtmlUnit is commonly used for web page test automation but can also be used for web scraping.

Uploaded by

linda976
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

HtmlUnit

HtmlUnit is a headless web browser written in


Java. It allows high-level manipulation of websites
HtmlUnit
from other Java code, including filling and
submitting forms and clicking hyperlinks. It also
provides access to the structure and the details Initial release May 22, 2002
within received web pages. HtmlUnit emulates Stable release 3.3.0 / June 4, 2023
parts of browser behaviour including the lower-
level aspects of TCP/IP and HTTP. A sequence Repository [Link]/HtmlUnit/htmlunit
such as getPage(url), ([Link]
getLinkWith("Click here"), mlunit)
click() allows a user to navigate through Written in Java
hypertext and obtain web pages that include
Operating system Cross-platform (JVM)
HTML, JavaScript, Ajax and cookies. This
headless browser can deal with HTTPS security, Available in English
basic HTTP authentication, automatic page Type Web browser
redirection and other HTTP headers. It allows Java
License Apache License 2.0
test code to examine returned pages either as text,
an XML DOM, or as collections of forms, tables, Website [Link]
and links.[1] ([Link]
o/)
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
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 specific Browser.

Drawbacks
Elements layout and rendering can not be tested.[4]
The JavaScript support is still not complete. And this is usually the main area of
enhancements.

Used technologies
W3C DOM
HTTP connection, using Apache HttpComponents ([Link]
JavaScript, using forked Rhino
HTML Parsing, NekoHTML ([Link]
CSS: using CSS Parser ([Link]
XPath support, using Xalan

Libraries using HtmlUnit


Selenium WebDriver
Spring MVC Test Framework ([Link]
ing-framework-reference/htmlsingle/#spring-mvc-test-server-htmlunit)
Google Web Toolkit tests ([Link]
ml)
WebTest ([Link]
Wetator ([Link]

See also
Free and open-
source software
portal

Headless system
PhantomJS a headless WebKit with JavaScript API
Web scraping
Web testing
xUnit
River Trail
Selenium WebDriver

References
1. "HtmlUnit Home" ([Link] Sourceforge. Retrieved 30 August 2019.
2. Beust, Cédric; Suleiman, Hani (15 October 2007). Next Generation Java Testing: TestNG
and Advanced Concepts ([Link]
&pg=SA4-PA109). ISBN 9780132702270. Retrieved 30 August 2019.
3. "HtmlUnit Driver" ([Link] Github.
Retrieved 30 August 2019.
4. "Testing HTML Unit" ([Link]
GWT Project. Retrieved 30 August 2019.

Bibliography
Beust, Cédric; Suleiman, Hani (15 October 2007). Next Generation Java Testing: TestNG
and Advanced Concepts ([Link]
9). ISBN 9780132702270. pp. 339– (subscription required)

Further reading
Langer, A. "Extending HtmlUnit for test automatisation of Web applications using AJAX" (htt
p://[Link]/[Link]?ID=183673); Betreuer/in (nen): T. Grechenig, M.
Bernhart; 183/1, 2009. (subscription required)
Massol, Vincent; Timothy M. O'Brien (2005). Maven: A Developer's Notebook ([Link]
org/details/isbn_9788173667916_g4l8/page/83). O'Reilly Media. pp. 83–86 ([Link]
org/details/isbn_9788173667916_g4l8/page/83). ISBN 978-0-596-55297-8.
Tahchiev, Petar; Felipe Leme; Vincent Massol (2010). "12. Presentation Layer Testing".
JUnit in Action (2 ed.). Manning. pp. 190–208. ISBN 978-1-935182-02-3.
Harold, Elliotte Rusty (16 March 2012). Refactoring HTML ([Link]
id=I2MKuc4iZDYC&pg=PA39). ISBN 9780132701877.
Tong, Ka Iok (23 April 2006). Enjoying Web Development with Tapestry ([Link]
[Link]/books?id=p5x9-ZKQF0sC&pg=PA347). ISBN 9781411649132.
Schalk, Chris; Burns, Ed; Holmes, James (25 August 2006). JavaServer Faces: The
Complete Reference ([Link]
t%22). ISBN 9780072262407. (subscription required)

External links
HtmlUnit ([Link]

Retrieved from "[Link]

You might also like