Andrew “Pandy” Knight, Lead Software Engineer in Test PrecisionLender, a Q2 Company, and Lead Developer for Boa Constrictor, talked about the challenges of traditional interactions, the benefits of Screenplay, and using Screenplay with Boa Constrictor.If you’re new to visual testing and have no idea what applitools are, there’s a quick way to figure things out.In these two almost identical images, you can see some differences. To be precise, there are 10 of them. This is the power of the visual AI developed by Applitools it can detect any differences between pictures in a split second.
Screenplay pattern – a new way to automate your interactionsScreenplay pattern is not entirely new, it has been around for several years. But still not familiar to many testers. First, we need to understand what interactions are. Interactions – how users operate software: loads, clicks, scrapes, etc. And the easiest way to define testing is interactions plus verification, i.e., you do something and then make sure that it works.As an example of a search test, consider the DuckDuckGo search engine. It’s simple here:
- Opening a search engine requires navigation.
- Searching for a phrase requires pressing the enter key and the search button.
- Checking the results requires clearing the page title and links to the results.
- The WebDriver object is initialized with the Chrome driver (if we’re testing Chrome).
- The first step is to open the search engine by calling driver.navigate.GoToURL (“DuckDuckGo website address”).
- The second step searches by retrieving the web elements using driver.findelement (it has multiple locators), and calls methods like send keys and click.
- The third step uses the headers to check the contents of the page header and the existence of links to the results.
- WebDriver closes the web browser for proper cleaning at the end of the test.
- There is someone who initiates the interaction – the user. Let’s call them Actor.
- There is a product under test – in our case, this is a web app.
- There are interactions themselves – for a web app, these can be simple keystrokes or more complex actions (login to the app or search for a page).
- Finally, there are the objects themselves, which allow users to make interactions. Let’s call them “ability.”
Benefits of Screenplay
- Rich, reusable, reliable interactions.
- Interactions are composable.
- Easy waiting.
- Readable, understandable calls.
- Covers all interactions – not just Web UI.