Playwright interview questions
// 42 QUESTIONS · UPDATED MAY 2026
Playwright interview questions covering locators, fixtures, storageState, parallel execution, the trace viewer, and cross-browser testing patterns.
Showing 42 of 42 questions
- What are user-facing locators and why does Playwright recommend them?Mid
User-facing locators (getByRole, getByLabel, getByText) target elements the way a user or assistive tech would. They're more resilient to…
- How does Playwright's storageState work and when would you use it?Senior
storageState is a JSON snapshot of cookies and origin storage that Playwright can save after a one-time login and inject into every test'…
- What is Playwright and what makes it different from Cypress and Selenium?Junior
Playwright is Microsoft's open-source automation framework. It drives Chromium, Firefox, and WebKit out of the box, supports multiple tab…
- What browsers does Playwright support?Junior
Chromium (Chrome, Edge), Firefox, and WebKit (Safari engine) — all bundled with Playwright. Plus channel options for installed Chrome / E…
- How do you install and configure Playwright in a TypeScript project?Junior
Run `npm init playwright@latest` for an interactive setup, or manually `npm i -D @playwright/test` followed by `npx playwright install` t…
- What is a Locator and how does it differ from an ElementHandle?Junior
A Locator is a *query description* — it re-runs every time you act on it, giving auto-retry. An ElementHandle is a *snapshot reference* t…
- What is the Playwright Test Runner and how is it different from running with Mocha/Jest?Junior
`@playwright/test` is Playwright's bundled runner. It's purpose-built for browser tests with built-in fixtures, parallel execution, proje…
- How do you take a screenshot in Playwright?Junior
Use `page.screenshot({ path: 'shot.png' })` for a viewport screenshot or `{ fullPage: true }` for the whole page. `locator.screenshot()`…
- What is page.goto() and what options does it accept?Junior
`page.goto(url)` navigates to the URL and resolves when a load event fires. Options include `timeout`, `waitUntil` ('load' default, 'domc…
- How do you assert text content in Playwright?Junior
Use `expect(locator).toHaveText(...)` for exact / regex match, `toContainText(...)` for substring, `toHaveValue(...)` for inputs, `toHave…
- Explain auto-waiting in Playwright.Mid
Before every action, Playwright waits for the element to be **actionable** — attached, visible, stable (not animating), enabled, and rece…
- What is a fixture in Playwright and how does it differ from beforeEach?Mid
A fixture is a named, scoped setup/teardown unit injected into tests by the runner. `beforeEach` runs setup imperatively for every test i…
- Compare locator strategies: getByRole vs getByTestId vs CSS selectors.Mid
`getByRole` matches by accessible name — most stable, double-duties as a11y testing. `getByTestId` is the explicit testing-attribute fall…
- How does Playwright handle cross-origin navigation differently from Cypress?Mid
Playwright treats cross-origin navigation as a normal navigation — same `page`, same APIs, no special config. Cypress historically blocke…
- What is the trace viewer and how do you use it to debug a failing test?Mid
The trace viewer is a post-run debugger that replays the test with DOM snapshots, network log, console, source code, and timeline. Enable…
- How do you parameterise Playwright tests with test.describe.parallel and projects?Mid
**Projects** parameterise tests by config — different browsers, viewports, or env vars. Each project runs the matching tests independentl…
- Walk me through how you'd test a feature with multiple browser contexts.Mid
Create independent contexts via `browser.newContext()` — each has its own cookies, storage, and cache, simulating different users. Each c…
- How do you intercept and mock network requests in Playwright?Mid
Use `page.route(pattern, handler)` to intercept matching requests. The handler can `fulfill` (mock the response), `continue` (pass throug…
- What is the difference between page.waitForResponse and page.waitForRequest?Mid
`waitForRequest` resolves when a matching request is *sent*. `waitForResponse` resolves when a matching response is *received*. Pair eith…
- How do you handle file downloads in Playwright?Mid
Listen for the `download` event with `page.waitForEvent('download')`, then save with `download.saveAs(path)` or read the path via `downlo…
- How do you handle file uploads in Playwright?Mid
Use `locator.setInputFiles(path)` on the `<input type=file>` element. Pass a path, multiple paths, an in-memory `{ name, mimeType, buffer…
- How do you test against multiple browsers in CI?Mid
Define a project per browser in `playwright.config.ts`. The runner spawns each project's tests in parallel by default. In CI, optionally…
- What is the Playwright Inspector and how does it speed up debugging?Mid
The Inspector is an interactive debugger that opens with `PWDEBUG=1 npx playwright test` or `page.pause()`. It lets you step through acti…
- How would you structure a POM for Playwright with shared base behaviour?Mid
Create a `BasePage` class with the `page` fixture and shared utilities (waiting helpers, URL navigation, common header interactions). Sub…
- Explain test.use() and when to override fixtures at the file level.Mid
`test.use({ ... })` overrides fixture values for all tests in the current file or describe block. Use it for per-file viewport, locale, s…
- How do you handle authentication state for tests that require different user roles?Mid
Pre-build a `storageState` JSON per role in a `setup` project that runs first. Each test project (or `test.use()` block) loads the right…
- How do you handle iframes in Playwright?Mid
Use `page.frameLocator(selector)` to get a frame-aware Locator, then chain normal Locator APIs. `frameLocator` works for same-origin and…
- What are Playwright projects and when would you use them?Mid
A project is a named bundle of test config — browser, viewport, env vars, fixtures, test selection — that the runner executes as one logi…
- How does Playwright run tests in parallel across workers, and what should be worker-scoped vs test-scoped?Senior
Each worker is a Node process with its own browser. By default tests in the same file run serially in a worker; tests in different files…
- How would you architect a Playwright suite for cross-browser visual regression?Senior
Use `expect(page).toHaveScreenshot()` with per-project baselines (Playwright auto-keys baselines by project name). Mask volatile elements…
- Walk through how you'd debug a Playwright test that flakes only in CI.Senior
Download the trace from the failed CI run and open with `show-trace` — DOM snapshots and network reveal the actual failure. Match local e…
- How do you handle environment-specific config and secret management in Playwright?Senior
Single `playwright.config.ts` driven by env vars (`process.env.BASE_URL`, etc.). Per-environment values come from CI variables, not commi…
- Compare Playwright's APIRequestContext for backend testing vs a separate API test framework.Senior
`APIRequestContext` (`request` fixture or `page.request`) makes HTTP calls with cookie/storage sharing with browser tests — ideal for set…
- How would you migrate from Cypress to Playwright incrementally?Senior
Set up Playwright alongside Cypress, port the highest-ROI specs first (smoke, top journeys), keep both running in CI until parity, retire…
- How would you set up sharding across multiple CI runners without Playwright Cloud?Senior
Use the built-in `--shard=N/M` flag. Each CI runner passes a unique shard index and the total. Playwright partitions tests deterministica…
- What's your strategy for handling extremely long E2E user journeys (10+ steps)?Senior
Don't write one mega-test. Decompose into independent stages — each verifiable from a known starting state via API setup. Reserve one can…
- How would you test a feature that depends on real-time WebSocket data?Senior
Two paths: (1) run a local mock WebSocket server (`ws` library or `mock-socket`) and point the app at it via env var — full handshake + m…
- How do you handle deterministic test data when tests run in parallel?Senior
Each test gets isolated data, namespaced by worker index or test ID. Two strategies: per-test seeding (worker fixture creates rows with u…
- What testability changes would you push for as a Playwright lead reviewing app code?Senior
Accessible markup (real `<button>`s with names, labels on inputs, ARIA roles) so `getByRole` works. Stable test IDs as a fallback. No liv…
- How does Playwright's tracing change your approach to debugging vs Cypress's time-travel debugger?Senior
Cypress's time-travel is *live* and interactive — you replay the test's snapshots in the open Test Runner. Playwright's trace is *post-ho…
- How would you set quality bars and SLA targets for a Playwright suite owned by a QA team?Lead
Track flake rate (<1%), suite duration (<30 min for full, <10 min for smoke), escape rate (<10% of prod bugs), and critical-journey cover…
- How would you justify the choice of Playwright over Cypress to a director skeptical of changing tools?Lead
Frame in business terms: cycle time, flake rate, escape rate, and the cost of multi-browser / multi-tab gaps. Bring data — current Cypres…