Screenplay: “Making test automation coding fun again”

The Screenplay Pattern is one of my favourite ways to code automation. As one tester I know said, it “makes test automation coding fun again”.
I don’t use it everywhere, but I do find a lot of situations where it would be my goto approach.
It’s more than just a design pattern, though — it really is a different way of thinking about automation.
The Page Object Pattern was originally designed as a way to introduce testers coming from a scripting background (such as HP Mercury at the time) to object oriented concepts such as encapsulation. It was not designed to be an overarching design approach, but one pattern that could be used amongst others.
But this approach has it’s limits — for one thing, it tends to create large classes that do a lot of different, unrelated things, which can make them harder to understand and to maintain.
But the biggest limitation in using an approach purely based on Page Objects is that it tends to make you think that everything should be tested via the UI, and to create a tight coupling between your test framework and the user interface of the application it tests.
The Screenplay pattern does things differently: it makes you reason in terms of what the goals user is trying to achieve, and what tasks they need to complete to achieve these goals. This gives us a lot more flexiblity in how we implement these tasks, which tends to make our automation code more readable (it’s written in business language) and more flexible (you get much more resuability out of business tasks than you do out of page components).
And this makes a big difference for larger test automation frameworks, that interact with larger or more complex applications, especially where lots of testers are involved.
Here are a few additional resources:
👉 The limitations of the Page Object model in terms of OO design principles, and how refactoring them using conventional software craft principles tends to lead to an approach like the Sceenplay pattern: https://loom.ly/ZEW5ED8
👉 The seminal article on Serenity Screenplay from 2016: https://loom.ly/vo4nZkg
👉 Page Objects That Suck Less — some of the limitations of a pure Page-Object approach, and how these can be overcome: https://loom.ly/NEe0ZCI
👉 A beginner tutorial for Screenplay using Serenity in Java: https://loom.ly/9ccwcXk
👉 A video demonstration of the Screenplay pattern in JavaScript/TypeScript with Serenity/JS (https://loom.ly/v4yQOkM): https://loom.ly/UtCyXoM
👉 A video introduction to Boa Constrictor, the .NET Screenplay implementation developed by Andrew Knight : https://loom.ly/XGoEZN0
👉 A good series of tutorials about Screenplay from Matt Wynne : (“Having tried several different approaches myself over the years, I’ve come to believe that the Screenplay pattern is the best technique we have today”): https://loom.ly/63yPr2c