11 Scalable test automation with the Screenplay pattern
This chapter covers
- Actor-centric testing and the Screenplay pattern
- Screenplay Actors
- Other related stuff
As your test automation framework grows, you quickly realize that your biggest problem isn’t knowing how to automate each new scenario; it’s being able to add these new scenarios while at the same time keeping your code base simple and maintainable. As your test suite interacts with different UI components, APIs, databases and more, keeping your code simple and consistent can be harder and harder to do.
The Screenplay Pattern, which we will be covering in this chapter, is an approach to keeping this complexity under control as our frameworks grow.
Let’s start with a quick example of how the Screenplay pattern can help us write cleaner, more maintainable test automation code.
11.1 What is the Screenplay Pattern and why do we need it?
In the previous couple of chapters, we’ve seen a few other approaches to help keep your test automation code clean. Page Objects are one example. We’ve seen how the Page Object Model can help to separate low-level WebDriver code from your step definition code, which can reduce duplication and simplify your step definition code.