Java Reference
In-Depth Information
The HtmlUnit pros are that it's a 100 percent Java solution, it's easy to integrate in a
build process, and Cactus can integrate HtmlUnit code for in-container testing, as can
other frameworks. HtmlUnit provides an HTML object model, which can validate web
pages to the finest level of detail. HtmlUnit also supports XP ath to collect data; Sele-
nium XP ath support is limited to referencing elements.
The Selenium pros are that the API is simpler and drives native browsers, which
guarantees that the behavior of the tests is as close as possible to a user installation.
12.10 Summary
In this chapter, we examined presentation-layer testing and explored the use of
two free open source tools to test the user interface of a web application: Html-
Unit and Selenium.
HtmlUnit is a 100 percent Java solution with no external requirements; it offers a
complete HTML object model, which, although creating rather verbose test code,
offers great flexibility.
Selenium is a more complex offering; it includes a simple IDE and many comple-
mentary components. The IDE generates test code but doesn't maintain it. The
strength of the product comes from its architecture, which allows the embeddable
Selenium Remote Control server to control different browsers on assorted operating
systems. The Selenium API is much simpler and flatter than with HtmlUnit, resulting
in more concise test code.
Use HtmlUnit when your application is independent of operating system features
and browser-specific implementations of JavaScript, DOM , CSS , and so on.
Use Selenium when you require validation of specific browsers and operating sys-
tems, especially if the application takes advantage of or depends on a browser's spe-
cific implementation of JavaScript, DOM , CSS , and so on.
In the next chapter, we add a layer of complexity by considering Ajax technologies
in our applications and test cases.
 
 
Search WWH ::




Custom Search