Playwright · Reliable end-to-end tests
How is Playwright architected?
Short answer
A test process talks to a Playwright driver that controls patched browser builds. Inside a browser, cheap isolated contexts hold pages, and each test gets its own context and page through fixtures.
Playwright has three useful layers to reason about: the test process, the browser driver, and the browser itself. The test process runs your TypeScript and the runner. It communicates with a Playwright driver, which launches and controls the browser. Inside the browser, contexts provide isolation and pages provide navigation and DOM access.
The layers
- The Node process runs the test runner, fixtures, assertions and reporting
- The Playwright driver owns the browser lifecycle and the protocol connection
- A browser instance is an OS process or process group for Chromium, Firefox or WebKit
- A browser context is an isolated session with its own cookies, storage and cache
- A page is a tab inside a context, with its own DOM, network and JavaScript world
import { chromium } from "playwright";
const browser = await chromium.launch();
const context = await browser.newContext();
const page = await context.newPage();
await page.goto("https://example.com");
await context.close();
await browser.close();Contexts are the isolation unit, not browser processes. Creating a context is cheap and does not require a new browser, so an entire test suite can reuse one browser per worker while every test still starts with clean storage. That is why a leaked cookie in one test does not normally affect the next.
Follow-ups you should expect
Interviewers use these to check whether the first answer was understanding or memorisation.
- 1What is the difference between a browser and a browser context?
- 2Why is creating a context cheaper than launching a browser?
- 3What does the Playwright driver do?
- 4How does the test runner map fixtures onto these layers?
Say it in the interview
Architecturally there is the test process, the Playwright driver, and the browser. The driver controls patched Chromium, Firefox or WebKit builds, and inside the browser a context provides an isolated session while a page is a tab in that context. The key point is that contexts are cheap and are the isolation unit, so each test can get fresh storage without paying for a new browser. The runner ties this together with fixtures like browser, context and page.
Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.
Related questions
Reading is step one
Now say it out loud.
Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Playwright mock interview and get scored feedback on depth, clarity and confidence.