Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the advantages/disadvantages of using the Screenplay pattern over Page objects?

I have watched a video on youtube that suggest using screenplay pattern as an alternative to using the usual pageobjects. The only advantage I see is that the page object classes are not as big. Is there something else I am missing ? I have been searching and all website are always referencing the example on the the youtube lecture using serenity bdd. Can someone explain why else is it better (or maybe worse) than using page objects?

An example that does not use serenity bdd would be really help.

like image 613
mosaad Avatar asked Mar 09 '23 10:03

mosaad


1 Answers

In a nutshell, ScreenPlay encourages better software engineering practices, and thus makes the tests faster to write and easier to maintain in the long term, but requires a better understanding of OOP to yield its full benefits (though it does scale remarkably well with junior engineers as long as there are a couple of senior engineers around who understand the pattern).

Page Objects where only ever intended as a stepping stone to help introduce automated testers to better test automation practices, but it can still lead to hard-to-maintain code. Take a look at this article for the origin story: https://ideas.riverglide.com/page-objects-refactored-12ec3541990.

There are a couple of other implementations of Screenplay, including: - JNarrate: https://bitbucket.org/testingreflections/jnarrate/wiki/Examples - Narrative: https://github.com/tim-group/narrative

ScreenPlay is an actor or user-centric model, which is easier to scale and more reusable than step libraries in many cases. Once a task is written, you rarely have to change it (respecting the Open-Closed Principle). An actor-centric model also makes it easier to model situations where several users interact in a scenario (for example, with different browsers). Jan Molak talks about the actor-centric side of Screenplay in this article: https://janmolak.com/user-centred-design-how-a-50-year-old-technique-became-the-key-to-scalable-test-automation-66a658a36555

like image 79
John Smart Avatar answered Apr 30 '23 16:04

John Smart