Home › Blog › Playwright Interview Questions (2026): 34 Questions With Answers, Beginner to Senior

Playwright Interview Questions (2026): 34 Questions With Answers, Beginner to Senior

Playwright interviews test whether you can write fast, reliable browser tests: user-facing locators and auto-waiting, web-first assertions, browser contexts and fixtures, login reuse with storageState, network mocking, parallel workers and sharding, and debugging with the trace viewer. As of November 17, 2026 the current release is Playwright 1.65 (patch 1.65.1 on npm since November 13), which drives Chromium, Firefox and WebKit from TypeScript or JavaScript, Python, Java and .NET.

Playwright interviews test whether you can write fast, reliable browser tests: user-facing locators and auto-waiting, web-first assertions, browser contexts and fixtures, login reuse with storageState, network mocking, parallel workers and sharding, and debugging with the trace viewer. As of November 17, 2026 the current release is Playwright 1.65 (patch 1.65.1 on npm since November 13), which drives Chromium, Firefox and WebKit from TypeScript or JavaScript, Python, Java and .NET. Below are 34 questions by level with strong answers, five debugging scenarios, and how interviews test the tool.

Playwright in November 2026: facts to know

FactDetail
Current version1.65, published November 5, 2026; 1.65.1 followed on November 13
LanguagesTypeScript and JavaScript with the Playwright Test runner; Python, Java and .NET bindings
BrowsersChromium, Firefox and WebKit builds that each release is tested against
Node.jsThe 1.65 release notes say Playwright no longer tests on Node.js 20; use 22, 24 or 26
Built inTest runner, fixtures, projects, retries, sharding, HTML report, trace viewer, UI mode, codegen
AI featuresTest Agents (planner, generator, healer), added in 1.56 in October 2025 and set up with npx playwright init-agents

Fundamentals

  1. What is Playwright, and how is it different from Selenium? An open-source browser automation library and test runner from Microsoft. It controls browsers over a persistent connection with its own protocol rather than W3C WebDriver commands through a separate driver, and ships auto-waiting, isolated contexts, tracing and parallel runs built in. Selenium is the WebDriver standard; see our Selenium interview questions.
  2. Explain Browser, BrowserContext and Page. A Browser is a launched browser process. A BrowserContext is an isolated session inside it, like a fresh profile with its own cookies, storage and permissions. A Page is one tab. Playwright Test gives every test a new context, which is cheap and isolates tests without restarting the browser.
  3. What does auto-waiting check before a click? Actionability: the element is attached, visible, stable (not animating), receives events (nothing covers it) and enabled; fill() also needs it editable. Since 1.65, actions also wait until the element is not inert. If the checks fail before the timeout, the error says which one.
  4. Which locators should you prefer? User-facing ones: getByRole, getByLabel, getByPlaceholder, getByText, getByAltText, getByTitle, and getByTestId for stable test ids. CSS and XPath are fallbacks. Example: page.getByRole('button', { name: 'Sign in' }). Role locators also surface accessibility bugs.
  5. What is the difference between a Locator and an ElementHandle? A locator is a lazy description that is resolved against the live DOM every time you act or assert, so re-renders don't break it. An ElementHandle points at one DOM node captured earlier and can go stale; the docs discourage handles for most work.
  6. What is strictness? An action on a locator that matches more than one element throws a strict mode violation instead of silently picking one. Narrow it with role and name, filter({ hasText: 'Pro plan' }), a container locator, or nth() when position is the point.
  7. What are web-first assertions? Assertions such as await expect(locator).toHaveText('Saved') retry until the condition holds or the expect timeout passes (5 seconds by default). expect(await locator.textContent()).toBe('Saved') reads once and never retries, a classic cause of flaky tests.
  8. Why is page.waitForTimeout() a code smell? A fixed sleep is either too long, which slows the suite, or too short, which makes it flaky. Wait for a condition instead: a web-first assertion, page.waitForURL() or page.waitForResponse().
  9. What are fixtures in Playwright Test? Values injected into tests by name, such as page, context, browser and request. Custom fixtures come from test.extend(): code before await use(value) is setup and code after it is teardown. Fixtures are test-scoped or worker-scoped and run only when a test asks for them.
  10. What goes in playwright.config? testDir, timeout (30 seconds per test by default), retries, workers, reporter, a use block with baseURL, trace, screenshot and video, projects for browsers or environments, and webServer to start the app before the tests.
  11. How do you create and run tests from the CLI? npx playwright codegen <url> records actions as a draft test. npx playwright test runs the suite, with a file or line, --project=firefox, --grep @smoke, --ui for UI mode, --debug for the Inspector and --last-failed to rerun failures.

Intermediate

  1. How do you avoid logging in before every test? Run a setup project that logs in once and saves await page.context().storageState({ path: authFile }). Other projects list it in dependencies and set use: { storageState: authFile }. Save one file per role; for one account per worker, use a worker-scoped fixture.
  2. How do you mock an API response? await page.route('**/api/orders', route => route.fulfill({ json: [] })). Use route.abort() to simulate a network failure, route.continue() to modify a request, and page.routeFromHAR() to replay recorded traffic.
  3. How do you wait for a request that a click triggers? Start waiting before the action: const resp = page.waitForResponse('**/api/save');, then click, then await resp. Awaiting only after the click can miss a fast response.
  4. Can Playwright test APIs? Yes. The request fixture is an APIRequestContext: const res = await request.post('/api/users', { data: { name: 'Ana' } }); await expect(res).toBeOK(); Use it to seed data before UI tests; page.request shares cookies with the page's context. More in our API testing interview questions.
  5. How does Playwright run tests in parallel? Test files run in parallel across worker processes, each with its own browser. Tests inside one file run in order unless you set fullyParallel: true or test.describe.configure({ mode: 'parallel' }).
  6. What is sharding? Splitting the suite across machines, for example npx playwright test --shard=1/4 on four CI jobs. Use the blob reporter on each shard and npx playwright merge-reports for one HTML report. Since 1.65 a sharded run fails with "No tests found" when no shard has tests, unless you pass --pass-with-no-tests.
  7. How do retries and flaky tests work? retries: 2 reruns failures, and a test that fails then passes is reported as flaky rather than passed. Pair retries with trace: 'on-first-retry' so every flaky failure leaves a trace, and track flaky tests instead of letting retries hide them.
  8. What does the trace viewer show? A timeline of every action with DOM snapshots before and after, the locator used, console output, network requests and errors. Open it with npx playwright show-trace trace.zip or from the HTML report. It is the first stop for a failure that only happens in CI.
  9. How do you handle iframes and popups? Frames: page.frameLocator('#payment').getByLabel('Card number'). Popups: create page.waitForEvent('popup') before the click, then await it to get the new Page.
  10. How do you write page objects in Playwright? A class that takes a Page, defines locators and exposes user-level methods such as login(email, password), with assertions kept in the tests. Since 1.65, TypeScript class fields follow useDefineForClassFields, so a field initializer that reads a constructor parameter property now fails; create those locators in the constructor.
  11. How do you run the same tests on several browsers? Define projects such as { name: 'webkit', use: { ...devices['Desktop Safari'] } } alongside Desktop Chrome and Desktop Firefox. The devices presets also emulate mobile viewports, touch and user agents.
  12. How does visual comparison work? await expect(page).toHaveScreenshot() compares against a baseline created on the first run and refreshed with --update-snapshots. Baselines differ by browser and OS, so generate them in the same Docker image as CI and use the mask option for dynamic regions.
  13. What are aria snapshots? expect(locator).toMatchAriaSnapshot(), added in 1.49, compares the accessibility tree with a YAML template. It checks structure and accessible names together and is less brittle than pixel comparison.

Experienced and senior

  1. How would you design a Playwright framework for 2,000 tests? Fixtures for auth, data and page objects; API seeding instead of UI setup; tags such as { tag: '@smoke' } with --grep; projects per browser and environment; fullyParallel plus sharding in CI; traces kept on failure; and an owner for every flaky test.
  2. How do you keep tests independent when they share a database? Give each test or worker its own data: unique emails built from testInfo.parallelIndex or a UUID, worker-scoped fixtures that create a tenant, and cleanup in fixture teardown. Serial mode is a last resort for flows that truly cannot be split.
  3. How do you test time-dependent features? The Clock API, added in 1.45: await page.clock.install({ time: new Date('2026-01-01T08:00:00') }), then page.clock.fastForward('30:00') or pauseAt() to test session timeouts and countdowns without waiting.
  4. How do you deal with unpredictable overlays such as cookie banners? page.addLocatorHandler(locator, handler), added in 1.42, runs your handler whenever that overlay appears and blocks an action. Better still, store the consent cookie in storageState so the banner never appears.
  5. What makes Playwright tests flaky, and how do you fix it? Non-retrying assertions, fixed sleeps, shared data, order dependence, hydration races where a click lands before handlers attach, and live third-party calls. Fix with web-first assertions, isolated data, mocked third parties and an assertion that the page is ready, then track flaky rate per test.
  6. How do you run Playwright in CI efficiently? Use the official Docker image or npx playwright install --with-deps, cache browsers, set forbidOnly: !!process.env.CI and two retries, shard across jobs, and upload the report and traces. 1.65 added a failures reporter and an onlyFailures report option.
  7. What are Playwright Test Agents? Three agent definitions added in 1.56: a planner that explores the app and writes a Markdown test plan, a generator that turns the plan into tests, and a healer that runs the suite and repairs failing tests. Set them up with npx playwright init-agents --loop=vscode. Add that generated tests and healer fixes still need review, because a healed locator can mask a real bug.
  8. When would you choose Playwright over Cypress? When you need WebKit, several tabs or origins in one test, languages beyond JavaScript, or out-of-process control. Cypress runs inside the browser and is JavaScript-only, which buys an excellent interactive runner; compare our Cypress interview questions.
  9. How do you test uploads and downloads? Uploads: await page.getByLabel('Resume').setInputFiles('cv.pdf'). Downloads: create page.waitForEvent('download') before the click, await it, then call saveAs() and assert on the file.
  10. How do you test two users interacting, such as a chat? Create two contexts in one test, each with its own storage state, for example browser.newContext({ storageState: 'alice.json' }), then drive both pages. Contexts are isolated, so this models two users on one machine.

Five debugging scenarios interviewers use

How interviews test Playwright

Companies don't publish their question banks, but candidates for SDET and QA automation roles commonly report the same formats:

Narrate as you work: which locator and why, what you assert, and what could make the test flaky.

Where CoPilot Interview fits

CoPilot Interview is an AI interview assistant whose free AI mock interview builds Playwright and QA automation questions from your résumé and the job description, reads them aloud and scores each spoken answer out of 10. The browser demo at /try has 145 practice questions in 10 tracks, scored out of 10, with no signup. The free plan gives 15 minutes a day of live help in sessions of up to 15 minutes, with AI mock interviews included; Standard costs $24.99 a month and Pro $39.99. For role-specific prep, see our guide to practicing QA engineer interviews with AI. Live coding tasks, take-homes and online assessments usually forbid outside help, so prepare for those; in any live interview, follow your employer's rules.

Disclosure: CoPilot Interview is our product, so weigh what we say about it accordingly.

Frequently asked questions

Is Playwright better than Selenium?

For new web projects many teams pick Playwright for auto-waiting, isolation, tracing and built-in parallel runs. Selenium stays strong where a WebDriver grid, older browsers or a large existing suite matter. Interviewers want the trade-offs, not loyalty to one tool.

Which language should I use in a Playwright interview?

The one the job uses. Playwright Test, the built-in runner, is the TypeScript and JavaScript option; Python teams usually use the official pytest plugin, and Java and .NET teams pair Playwright with their usual test frameworks.

What is the latest Playwright version?

As of November 17, 2026 it is 1.65, with patch 1.65.1 published on November 13. Its release notes recommend Node.js 22, 24 or 26.

Can Playwright test mobile apps?

It emulates mobile browsers through device presets for viewport, touch and user agent, but it does not automate native iOS or Android apps. That is Appium's job; see our <a href="/blog/appium-interview-questions">Appium interview questions</a>.

How do I prepare for a Playwright interview?

Build a small suite against a demo app: login reused with storageState, one mocked API, one visual check, and CI with sharding and traces. Then practice explaining each decision out loud.

Practice this interview before the real one

The AI mock interview builds questions from your resume and the job description, reads them aloud and scores each spoken answer out of 10. Included on the free plan.

Start a mock interview