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:
type Roles = { customer: Page; operator: Page };
const asRole = (role: string) => async (
{ browser }: { browser: Browser },
use: (p: Page) => Promise<void>,
) => {
const ctx = await browser.newContext({
storageState: '.auth/' + role + '.json',
});
await use(await ctx.newPage());
await ctx.close();
};
export const test = base.extend<Roles>({
customer: asRole('customer'),
operator: asRole('operator'),
});
And a scenario with two roles without orchestration in the test body:
// tasks are functions of a role; a question is a locator
const 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 }) => {
await submitTransfer(customer, 'UA002', 50_001);
await operator.getByRole('button', { name: 'Approve' }).click();
await expect(customer.getByTestId('status')).toHaveText('Approved');
});
Before agreeing
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
POM + fixtures + steps
Known to most people, covers the needs of a medium project.
Screenplay
Pays off in a complex domain with many roles and long-lived tests.
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.