In this talk, Andrew Knight explains the Screenplay pattern, which models test interactions as actors using abilities to perform actions. He covers why raw Selenium WebDriver calls duplicate code and race with page loading, the benefits of Screenplay, and how the open-source C# library Boa Constrictor applies it.
- Interactions plus verification as a definition of testing, shown on a DuckDuckGo search test
- Why raw WebDriver code duplicates logic and races with the page
- The Actor, ability and interaction roles that make up Screenplay
- Five benefits: reusable, composable, easy waiting, readable, and not limited to web UI
- Using Screenplay through the Boa Constrictor C# library
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 interactions
Screenplay 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.
While most teams use Selenium WebDriver, they all do it differently. There is a problem of code duplication and unreliability, so it’s time to consider how teams develop their interactions based on WebDriver.When teams start writing test automation code with Selenium WebDriver, they often write raw calls. Let’s look at some of them:
- 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.

The problem is that there are at least 3 race conditions in this code, in which the automation does not wait for the page to be ready for interactions. WebDriver does not automatically wait for elements to load or headers to appear, you must do this manually. And this is one of the reasons why we call such tests unreliable.But there must be a better way to handle interactions, right? Fortunately, it exists. Let’s take a closer look at how the interactions happen.

- 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.”
All this can be summarized: Users use abilities to perform interactions. This is the essence of the Screenplay pattern.
Benefits of Screenplay
- Rich, reusable, reliable interactions.
- Interactions are composable.
- Easy waiting.
- Readable, understandable calls.
- Covers all interactions – not just Web UI.
Boa Constrictor
Boa Constrictor — open-source C# implementation of the Screenplay Pattern, developed by PrecisionLender, a Q2 company. It can be used with any .NET test framework, like SpecFlow or NUnit. It helps you make better interactions for better automation.