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

1

5

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.

Dishcloth answered 5/4, 2017 at 12:31 Comment(0)
C
9

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

Cordero answered 5/4, 2017 at 18:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.