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
| Fact | Detail |
|---|---|
| Current version | 1.65, published November 5, 2026; 1.65.1 followed on November 13 |
| Languages | TypeScript and JavaScript with the Playwright Test runner; Python, Java and .NET bindings |
| Browsers | Chromium, Firefox and WebKit builds that each release is tested against |
| Node.js | The 1.65 release notes say Playwright no longer tests on Node.js 20; use 22, 24 or 26 |
| Built in | Test runner, fixtures, projects, retries, sharding, HTML report, trace viewer, UI mode, codegen |
| AI features | Test Agents (planner, generator, healer), added in 1.56 in October 2025 and set up with npx playwright init-agents |
Fundamentals
- 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.
- 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.
- 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. - Which locators should you prefer? User-facing ones:
getByRole,getByLabel,getByPlaceholder,getByText,getByAltText,getByTitle, andgetByTestIdfor stable test ids. CSS and XPath are fallbacks. Example:page.getByRole('button', { name: 'Sign in' }). Role locators also surface accessibility bugs. - 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.
- 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, ornth()when position is the point. - 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. - 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()orpage.waitForResponse(). - What are fixtures in Playwright Test? Values injected into tests by name, such as
page,context,browserandrequest. Custom fixtures come fromtest.extend(): code beforeawait 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. - What goes in playwright.config?
testDir,timeout(30 seconds per test by default),retries,workers,reporter, auseblock withbaseURL,trace,screenshotandvideo,projectsfor browsers or environments, andwebServerto start the app before the tests. - How do you create and run tests from the CLI?
npx playwright codegen <url>records actions as a draft test.npx playwright testruns the suite, with a file or line,--project=firefox,--grep @smoke,--uifor UI mode,--debugfor the Inspector and--last-failedto rerun failures.
Intermediate
- 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 independenciesand setuse: { storageState: authFile }. Save one file per role; for one account per worker, use a worker-scoped fixture. - How do you mock an API response?
await page.route('**/api/orders', route => route.fulfill({ json: [] })). Useroute.abort()to simulate a network failure,route.continue()to modify a request, andpage.routeFromHAR()to replay recorded traffic. - How do you wait for a request that a click triggers? Start waiting before the action:
const resp = page.waitForResponse('**/api/save');, then click, thenawait resp. Awaiting only after the click can miss a fast response. - Can Playwright test APIs? Yes. The
requestfixture 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.requestshares cookies with the page's context. More in our API testing interview questions. - 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: trueortest.describe.configure({ mode: 'parallel' }). - What is sharding? Splitting the suite across machines, for example
npx playwright test --shard=1/4on four CI jobs. Use theblobreporter on each shard andnpx playwright merge-reportsfor 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. - How do retries and flaky tests work?
retries: 2reruns failures, and a test that fails then passes is reported as flaky rather than passed. Pair retries withtrace: 'on-first-retry'so every flaky failure leaves a trace, and track flaky tests instead of letting retries hide them. - 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.zipor from the HTML report. It is the first stop for a failure that only happens in CI. - How do you handle iframes and popups? Frames:
page.frameLocator('#payment').getByLabel('Card number'). Popups: createpage.waitForEvent('popup')before the click, then await it to get the new Page. - How do you write page objects in Playwright? A class that takes a
Page, defines locators and exposes user-level methods such aslogin(email, password), with assertions kept in the tests. Since 1.65, TypeScript class fields followuseDefineForClassFields, so a field initializer that reads a constructor parameter property now fails; create those locators in the constructor. - 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. Thedevicespresets also emulate mobile viewports, touch and user agents. - 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 themaskoption for dynamic regions. - 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
- 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;fullyParallelplus sharding in CI; traces kept on failure; and an owner for every flaky test. - How do you keep tests independent when they share a database? Give each test or worker its own data: unique emails built from
testInfo.parallelIndexor 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. - 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') }), thenpage.clock.fastForward('30:00')orpauseAt()to test session timeouts and countdowns without waiting. - 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 instorageStateso the banner never appears. - 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.
- How do you run Playwright in CI efficiently? Use the official Docker image or
npx playwright install --with-deps, cache browsers, setforbidOnly: !!process.env.CIand two retries, shard across jobs, and upload the report and traces. 1.65 added afailuresreporter and anonlyFailuresreport option. - 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. - 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.
- How do you test uploads and downloads? Uploads:
await page.getByLabel('Resume').setInputFiles('cv.pdf'). Downloads: createpage.waitForEvent('download')before the click, await it, then callsaveAs()and assert on the file. - 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
- Passes locally, times out in CI. Open the CI trace first. Usual causes: a slower machine exposing a missing wait, a smaller viewport that collapses a menu, or missing seed data. Fix the wait or the data; a longer timeout only hides it.
- "strict mode violation: resolved to 2 elements." The locator matches, say, a header and a footer link. Scope it to a region,
page.getByRole('navigation').getByRole('link', { name: 'Pricing' }), rather than adding.first(). - "Element intercepts pointer events." A toast, modal backdrop or sticky header covers the target. Assert it is gone, close it, or register a locator handler;
force: trueskips the check and the bug with it. - Every test spends eight seconds logging in. Move login into a setup project with storageState, or log in through the API inside a fixture.
- The suite takes 40 minutes. Turn on fullyParallel, shard across CI machines, seed data through the request fixture, mock slow third parties, and run a tagged smoke suite on pull requests. The HTML report's Speedboard tab (added in 1.57) then lists the slowest tests.
How interviews test Playwright
Companies don't publish their question banks, but candidates for SDET and QA automation roles commonly report the same formats:
- A live task: automate a login or add-to-cart flow on a demo app, with sensible locators and real assertions.
- A code review: find the problems in a flaky test, such as fixed sleeps, non-retrying assertions, brittle CSS chains and shared state.
- A design discussion: framework structure, CI, sharding, reporting and what belongs at the UI, API or unit level; our QA engineer interview questions cover that strategy ground.
- Language basics: promises and async/await, since every Playwright call is asynchronous; see our TypeScript interview questions.
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