Screenplay builds a test around people, not screens: an actor with abilities performs tasks composed of interactions and asks questions about the system. The roles Actor, Ability, Task, Interaction and Question separate what, how and with what. In TypeScript it is implemented by Serenity/JS. It pays off in complex domains with several roles; in a small app it only adds layers.
Patterns · Screenplay
A scenario has a customer, an operator and an admin. Who orchestrates whom if all we have is pages?
The test “an operator approves a large transfer” involves two people and two pages. With Page Objects the test creates two contexts and two pages by hand and arranges who does what in its own variables. The more roles, the more of this orchestration sits in the test body. Screenplay builds the test around people, not screens, so a role becomes a first-class thing, not a variable.
How it works and why. Screenplay grew out of the idea of describing automation in the language of interaction designers: roles, goals, tasks, actions (Kevin Lawrence and Antony Marcano, 2007; later it went into Serenity BDD, and for TypeScript it is implemented by Serenity/JS). The core concepts:
Actor: who acts (“Olena, a bank customer”).
Ability: what the actor can do. It is access to the outside world: drive a browser, call an API, take notes. The Playwright Test adapter gives every actor the abilities to drive a browser, call an API and take notes without extra code.
Task: a business task made of other tasks and interactions (“Transfer money”).
Interaction: a low-level action: a click, typing text.
Question: what the actor can learn about the system: text, state, an API response. Questions are used in checks.
Why so many layers. Each has one responsibility: a task says what, an interaction says how in this interface, an ability provides with what. The same actor with another ability (an API instead of a browser) performs the same task by another path. So tasks are small and easy to combine, while a Page Object that collects everything from a page grows.
Five concepts
Figure 1. A task consists of interactions and the actor performs it with their abilities.
Example: before and after. Before: Page Objects and two contexts that the test holds by hand.
Limits and alternatives. Screenplay pays off when there are many roles and a complex domain. For a small app with one role it adds layers without solving a problem. Also, the team has to learn the model and the library, and locators and actions still have to be written. The comparison with Page Object and where it applies is in the next lesson.
What a class is about
Page Object
Here is a page
A class describes a screen: locators and methods. The test assembles a scenario from pages.
Screenplay
Here is an actor
A class describes behaviour: tasks and questions. The scenario reads as a person's story.
Figure 2. Two equal models: Page Object groups by screen, Screenplay by behaviour.
Common mistakes.
A task made of one interaction (“ClickConfirm”): that is a wrapper without business meaning, and a task should be named in the domain language.
A task named by the interface, not by intent (“FillFormAndPressButton”): when the UI changes, the name changes too.
One actor for the whole suite that changes data: roles and state mix; create an actor per scenario.
A check inside a task: it hides the expectation. Check with questions through Ensure.that in the scenario.
Taking Screenplay only because it is fashionable, with no complex domain and several roles.
Check yourself
How does a Task differ from an Interaction and why separate them?
Answer
An Interaction is one action in a concrete interface (a click, typing), a Task is a business task composed of other tasks and interactions. The split separates intent from method: when the UI changes the interactions are edited and the scenario with tasks stays.
Why does Screenplay have Questions if the value can be read from an element directly?
Answer
A question is part of the scenario language: “what the actor sees” reads the same whether it is text on a page or an API response. It can be reused in checks and combined with Ensure.that, without knowing about the locator in the test.
Related lessons: “Screenplay vs POM: when not to”, “What problem Page Object solves”, “Facade and business steps”, “Composition instead of inheritance”.
In an interview.Junior: Screenplay models a test through actors, their abilities, tasks and questions to the system, not through pages. In TypeScript it is implemented by Serenity/JS. Middle/Senior: It separates intent from method: a task says what, an interaction says how, an ability says with what. It scales well to complex domains with several roles, but has a higher entry cost, so before choosing it I check that there is a real problem it solves.
Screenplay vs POM: when not to
Screenplay fits when roles are many, the domain is complex and the team will learn the model; otherwise Page Objects with components and fixtures suffice. A Page Object groups code by screen, Screenplay by a person's behaviour, and each cures its own pain. So before switching, ask which problem it solves: plain Playwright already gives roles as fixtures and steps with test.step.
Patterns · Screenplay
The lead says: we are moving to Screenplay. What to ask before agreeing?
A decision “we change the approach to test structure” is expensive: new concepts for the whole team, rewriting existing code, a period when two models live together. So at a senior interview what is expected is not a liking for Screenplay or POM but an assessment of the trade-off. This lesson is about the signs that justify each.
How it works and why. A Page Object groups code by screen, Screenplay by a person's behaviour. Each solves its own pain. POM removes locator duplication and the test's coupling to markup. Screenplay removes the growth of page classes and the orchestration of roles, and makes business tasks the language of the scenario. So the deciding question is not “which is better” but “what problem do we have”.
Criterion
POM + fixtures
Screenplay
Entry cost
low
high
Prevalence in Playwright
the standard
a niche
Several roles in a scenario
through fixtures
natural
Amount of code
less
more small classes
Both columns are honest: Screenplay wins where it is complex, POM where it is simple.
What Playwright fixtures already give. Most of the benefits of Screenplay can be had in plain Playwright: roles are fixtures, business tasks are functions or a facade with test.step, questions are locators with web-first assertions. Here roles as fixtures, each with its own saved state:
And a scenario with two roles without orchestration in the test body:
// tasks are functions of a role; a question is a locatorconst submitTransfer = (who: Page, to: string, amount: number) =>
test.step('submit ' + amount + ' to ' + to, async () => {
await who.goto('/transfers');
await who.getByLabel('To').fill(to);
await who.getByLabel('Amount').fill(String(amount));
await who.getByRole('button', { name: 'Confirm' }).click();
});
test('operator approves a large transfer', async ({ customer, operator }) => {
awaitsubmitTransfer(customer, 'UA002', 50_001);
await operator.getByRole('button', { name: 'Approve' }).click();
awaitexpect(customer.getByTestId('status')).toHaveText('Approved');
});
Before agreeing
Figure 1. Four questions give the answer faster than an argument about taste.
Limits and alternatives. Screenplay is justified when many actors interact in one scenario (a customer, an operator, an admin), the domain is complex, tests live for years and the team is ready to learn the model. It is not worth taking when:
the team is small or of mixed levels, and the entry cost becomes a bottleneck;
the project is medium-sized and POM with components and fixtures already covers the needs;
a fashionable framework is wanted without a real problem it solves.
Two legitimate choices
Lower risk
POM + fixtures + steps
Known to most people, covers the needs of a medium project.
Higher payoff
Screenplay
Pays off in a complex domain with many roles and long-lived tests.
Figure 2. Neither is “better” without context: these are different risks and different payoffs.
Common mistakes.
Claiming Screenplay is “better than POM” without context. An answer without a trade-off is weak.
Dismissing Screenplay without knowing its idea: at an interview it matters to explain what it solves.
Migrating everything at once: two models in one repository without a plan, and the team gets confused in both.
Taking Serenity/JS for the reports while not using roles and tasks: you pay with complexity for one feature.
Copying Screenplay terms into a POM project to no benefit: “Task” and “Action” as new names for the same methods.
Check yourself
A team of four tests a web app with one user role. The lead proposes Screenplay. What to answer?
Answer
Ask what problem it solves. One role removes the main benefit of Screenplay (orchestrating roles), and the entry cost lands on everyone. POM with components, fixtures and a steps facade covers the needs cheaper. Return to the question when roles and a complex domain appear.
What from Screenplay can be taken into a POM project without the library itself?
Answer
Roles as fixtures with separate storageState, business tasks as functions or a facade with test.step, and questions as locators with web-first assertions. The test then also reads as behaviour, without a new tool.
Related lessons: “What Screenplay is”, “Facade and business steps”, “Fixtures: DI built into Playwright Test”, “Page Component: what it is and why”.
In an interview.Junior: I know Screenplay and understand its benefits for complex domains with several roles. For most Playwright projects I choose POM with components and fixtures: the entry cost is lower and the team writes tests faster. Middle/Senior: Before changing the approach I ask what problem we solve, how many roles the scenarios have and who will maintain it. Many benefits, such as roles, business steps and reporting through test.step, come from fixtures alone. So I take Screenplay when there are many roles, a complex domain and a team ready to learn the model.