It allows high-level manipulation of websites from other Java code, including filling and submitting forms and clicking hyperlinks.
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.
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.