Chapter 4: Interacting with a page
Thanks to Chapter 3, Navigating through a website, we now know how to open a browser and all the different options we have to launch browsers and create new pages. We also know how to navigate through other pages. We learned about HTTP responses and how they are related to a request.
This chapter is about interaction. Emulating user interaction is essential in UI testing. There is one pattern in unit testing called Arrange-Act-Assert (AAA). This pattern enforces a particular order in the test code:
- Arrange – Prepare the context.
- Act – Interact with the page.
- Assert – Check the page reaction.
In this chapter, we will learn how to find elements on a page. We will understand how the development team can improve their HTML so that you can easily find elements. But if you cannot change the page HTML, we will also look at another set of tools to find the elements we need.
Once we find an element, we will...