10 Automating acceptance criteria for the UI layer

 

This chapter covers

  • Why and when you should write automated UI tests
  • Using tools like Selenium WebDriver in Java to automate web tests
  • Finding and interacting with page elements in your tests
  • Design patterns to write more maintainable web tests

In the previous chapter, you learned how using a layered approach to automated acceptance testing helps make your tests clearer, more robust, and more maintainable. We discussed the three broad layers used in well-designed automated acceptance tests: the Business Rules layer, the Business Flow layer, and the Technical layer. In the following few chapters, we’ll focus on approaches and tools that can be used to implement the Technical layer, starting with the user interface.

In this chapter we’ll discuss techniques to automate UI tests for web-based applications. Users interact with an application through its user interface, and in modern web applications the UI implementation plays a major role in the overall user experience. The screenshots from automated web tests can be a valuable aid for testers, and they’re also a great way to provide illustrated documentation describing how the application behaves.

We’ll look at automated web testing from several perspectives, as well as a few popular automation libraries used for web testing:

10.1  When and how should you test the UI?

10.2  Where does UI testing fit in your test automation strategy?

10.2.1 Which scenarios should be implemented as UI tests?

10.2.2 Illustrating user journeys

10.2.3 Illustrating business logic in the user interface

10.2.4 Documenting and verifying screen-specific business logic

10.2.5 Showing how information is rendered in the user interface

10.2.6 Automating web-based acceptance criteria using Selenium WebDriver

10.2.7 Getting started with WebDriver in Java

10.2.8 Setting up a WebDriver driver

10.2.9 Integrating WebDriver with Cucumber

10.2.10 Sharing WebDriver instances between step definition classes

10.2.11 Interacting with the web page