Recently I gave a presentation at the Dutch Testnet Autumn conference about the Screenplay pattern.
It was nice to attend a conference in person again and meet old friends, enjoy the company of fellow testers and enjoy good food!
The slidedeck of this presentation can be found here (pdf)
For me, the Screenplay patterns gives me guidance on how to add the correct abstraction layers to my test automation code. What happens very often is that test automators apply the PageObject pattern (as recommended by Selenium), but the PageObjects become too large. The Screenplay pattern helps you with that issue.
There are several good introductions on the Screenplay pattern already:
- Kevin Lawrence was the first to go in that direction in 2007 with this article
- Antony Marcano, Andy Palmer and Jan Molak made a first implementation in 2012 with screenplay-jvm
- John Ferguson Smart joined Antony, Andy and Jan have a good article from 2016 on Page Objects Refactored
- Same guys also have a good explanation of it in another article
I’m not going to repeat everything here. Just wanted to say what are the essentials for me:
- Tasks allow the user to do things on the applications through smaller actions
- Questions allow the user to retrieve data from the application, for verifications, but also to guide decisions in Tasks
- Abilities allow to execute these Tasks or Questions, for example using WebDriver, or accessing an API
- it gives guidance how to structure your classes for the right abstraction levels
Several frameworks have extra support for the Screenplay pattern, but it can be implemented in any tool or language.
It is just that these frameworks have special base classes for Tasks, Question and Abilities that allow for a more fluent programming style.