HtmlUnit
{{
multiple issues
| {{
more footnotes needed | date=November 2015
}}
{{
primary sources | date=June 2013
}}
}}
{{Infobox software
| name = HtmlUnit
| logo = htmlunit logo.png
| screenshot =
| caption =
| developer =
| released = {{start date|2002|05|22}}
| latest release version = 4.4.0
| latest release date = {{start date and age|2024|07|28}}
| programming language = Java
| operating system = Cross-platform (JVM)
| platform =
| language = English
| genre = Web browser
| license = Apache License 2.0
| website = [https://htmlunit.sourceforge.io/ https://htmlunit.sourceforge.io/]
}}
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.{{cite web|url=http://htmlunit.sourceforge.net/|title=HtmlUnit Home|website=Sourceforge|access-date=30 August 2019}}
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.{{cite book|url=https://books.google.com/books?id=bCvcMcLZwV4C&q=htmlunit&pg=SA4-PA109|title=Next Generation Java Testing: TestNG and Advanced Concepts|isbn=9780132702270|access-date=30 August 2019|last1=Beust|first1=Cédric|last2=Suleiman|first2=Hani|date=15 October 2007|publisher=Pearson Education }}
- Compared to other WebDriver implementations, HtmlUnitDriver is the fastest to implement.{{cite web|url=https://github.com/SeleniumHQ/selenium/wiki/HtmlUnitDriver|title=HtmlUnit Driver|website=Github|access-date=30 August 2019}}
- It can be configured to simulate a specific browser.
Drawbacks
- Element layout and rendering can not be tested.{{cite web|url=http://www.gwtproject.org/doc/latest/DevGuideTestingHtmlUnit.html|title=Testing HTML Unit|website=GWT Project|access-date=30 August 2019}}
- The JavaScript support is not complete, which is one of the areas of ongoing enhancements.
Used technologies
Libraries using HtmlUnit
- Selenium WebDriver
- [http://docs.spring.io/spring/docs/4.2.0.BUILD-SNAPSHOT/spring-framework-reference/htmlsingle/#spring-mvc-test-server-htmlunit Spring MVC Test Framework]
- Google Web Toolkit [http://www.gwtproject.org/doc/latest/DevGuideTestingHtmlUnit.html tests]
- [https://web.archive.org/web/20101103111609/http://webtest.canoo.com/ WebTest]
- [http://www.wetator.org/ Wetator]
See also
{{Portal|Free and open-source software}}
References
{{Reflist}}
Bibliography
- {{cite book|url=https://books.google.com/books?id=bCvcMcLZwV4C&pg=PA339|title=Next Generation Java Testing: TestNG and Advanced Concepts|isbn=9780132702270|last1=Beust|first1=Cédric|last2=Suleiman|first2=Hani|date=15 October 2007|publisher=Pearson Education }} pp. 339– {{subscription required}}
Further reading
- Langer, A. [http://pub-inf.tuwien.ac.at/showentry.php?ID=183673 "Extending HtmlUnit for test automatisation of Web applications using AJAX"]; Betreuer/in (nen): T. Grechenig, M. Bernhart; 183/1, 2009. {{subscription required}}
- {{cite book |last1=Massol |first1=Vincent |author2=Timothy M. O'Brien |title=Maven: A Developer's Notebook |year=2005 |publisher=O'Reilly Media |isbn=978-0-596-55297-8 |pages=[https://archive.org/details/isbn_9788173667916_g4l8/page/83 83–86] |url=https://archive.org/details/isbn_9788173667916_g4l8/page/83 }}
- {{cite book |last1=Tahchiev |first1=Petar |author2=Felipe Leme |author3=Vincent Massol |title=JUnit in Action |edition=2 |year=2010 |publisher=Manning |isbn=978-1-935182-02-3 |pages=190–208 |chapter=12. Presentation Layer Testing}}
- {{cite book|url=https://books.google.com/books?id=I2MKuc4iZDYC&pg=PA39|title=Refactoring HTML|isbn=9780132701877|last1=Harold|first1=Elliotte Rusty|date=16 March 2012|publisher=Addison-Wesley Professional }}
- {{cite book|url=https://books.google.com/books?id=p5x9-ZKQF0sC&pg=PA347|title=Enjoying Web Development with Tapestry|isbn=9781411649132|last1=Tong|first1=Ka Iok|date=23 April 2006|publisher=TipTec Development }}
- {{cite book|url=https://books.google.com/books?id=vwzk3dRtEhcC&q=%22HtmlUnit%22|title=JavaServer Faces: The Complete Reference|isbn=9780072262407|last1=Schalk|first1=Chris|last2=Burns|first2=Ed|last3=Holmes|first3=James|date=25 August 2006|publisher=McGraw Hill Professional }} {{subscription required}}
External links
- [https://htmlunit.sourceforge.io/ HtmlUnit]
- [https://crawlbase.com/ Data Crawling and Scraping Platform]
{{web browsers}}
Category:Unit testing frameworks
Category:Free software programmed in Java (programming language)