Playwright interview questions, with answers that show real experience
By Denis Bojkovski, Test Automation Architect · Published December 2, 2026
Why Playwright questions come up so often
Playwright is the tool remote QA listings name most. On 1 December 2026, 29 of the 190 open roles on QAAnywhere named it, ahead of Selenium (24) and Cypress (12). Most of those roles want more than one tool: 18 of the 29 also named Selenium, and 8 named REST Assured or Postman. The languages split roughly evenly: 15 descriptions mention Java, 14 TypeScript or JavaScript and 12 Python, and 18 mention CI/CD pipelines.
So expect two kinds of question: how Playwright itself works, and how you would use it in a team's pipeline. The answers below are short on purpose. In the interview, add an example from a suite you have built, even a personal one.
Core concepts
"What makes Playwright tests less flaky than older tools?"
Three things. First, auto-waiting: before clicking or typing, Playwright checks that the element is attached, visible, stable, enabled and able to receive events. Second, web-first assertions: expect(locator).toHaveText(...) retries until the condition holds or the timeout expires, instead of checking once. Third, isolation: each test gets a fresh browser context, like a new browser profile, so cookies and storage never leak between tests. Then add the honest part: flakiness still comes from shared test data, timing in the application and environments, and no tool fixes those.
"Which locators do you prefer, and why?"
User-facing ones: getByRole('button', { name: 'Save' }), getByLabel, getByText. They follow what a user or screen reader sees, so they survive styling changes and push the team towards accessible markup. Next comes getByTestId for elements without a good role or label. CSS and XPath tied to the page structure come last. Also mention that a locator is lazy: it is resolved each time it is used, which is why it does not go stale the way a stored element reference can.
"What is a browser context, and why does it matter?"
A context is an isolated session inside one browser process, with its own cookies, storage and cache. Creating one is cheap, so each test can have its own without starting a new browser. Contexts also let you test two users at once, for example a buyer and a seller in the same test.
"Why should you avoid waitForTimeout?"
A fixed wait is slow when the app is fast and still fails when it is slower than expected. Wait for the thing you actually need instead: an assertion on the element, waitForResponse for a specific API call, or waitForURL after navigation.
Test structure and fixtures
"What are fixtures in Playwright Test?"
Fixtures provide what a test needs (page, context, request, or your own objects such as a logged-in page or a page object) and clean up after it. They are set up only when a test asks for them, and they can be scoped to a test or to a worker. Custom fixtures replace most beforeEach code and keep tests short. A good answer includes an example: a fixture that creates a user through the API and hands the test a page object already signed in as that user.
"How do you handle login without logging in through the UI in every test?"
Log in once in a setup project, save the browser state with storageState, and point the other projects at that file. Tests then start authenticated. For several roles, save one state file per role. Mention the trade-off: the login form itself still needs a few dedicated tests.
"Would you use the page object model with Playwright?"
Usually yes, but lightly: classes that expose user actions (checkout.payWithCard()) and locators, with assertions kept in the tests. Many teams combine page objects with fixtures, so tests receive ready-made page objects. The guide to test automation framework design covers how to structure the layers.
Running at scale
"How do you make a large suite fast?"
Run test files in parallel across workers (fullyParallel runs tests within a file in parallel too); split the suite across CI machines with --shard=1/4; set up data through the API rather than the UI; mock slow or unstable third-party calls with page.route; and run only a smoke set on every commit if the full suite is long. Measure before and after: the slowest ten tests are usually where most of the time goes.
"How do you run tests on several browsers?"
With projects in playwright.config: one per browser or device (Chromium, Firefox, WebKit, mobile viewports). Many teams run Chromium on every pull request and the full matrix nightly. Know that WebKit in Playwright is not the same as Safari on a Mac or an iPhone; it is close, but real-device checks may still be needed.
"Should you turn on retries?"
Retries in CI are fine as a safety net, as long as tests that pass only on retry are reported as flaky and fixed. Playwright marks them as flaky in its report, which makes that easy to track. Retries that hide failures make the suite less trustworthy over time.
Network, APIs and the browser
- "How do you mock an API response?"
page.route('**/api/orders', route => route.fulfill({ json: [...] })). Use it for error states and edge cases that are hard to create in a real backend, not to replace every backend call. - "Can Playwright test APIs?" Yes: the
requestfixture (anAPIRequestContext) sends HTTP requests and can share cookies with the browser context. It is ideal for test setup and for API checks that sit next to UI tests. - "How do you deal with iframes and new tabs?"
frameLocatorfor iframes. For a new tab, wait for the context'spageevent while clicking the link, then work with the new page object. - "How do you test file downloads and uploads?"
setInputFilesfor uploads; wait for thedownloadevent for downloads, then check the saved file.
Debugging
"A test passes locally but fails in CI. Walk me through it."
Open the trace first: with trace: 'on-first-retry' or 'retain-on-failure', the Trace Viewer shows each action, the DOM before and after it, network calls and console logs. Then compare environments: viewport size, time zone, locale, browser version, data and parallel workers sharing state. Reproduce locally with the same settings (--workers matching CI, the same environment variables). The guide to flaky tests in CI goes through the common causes.
Also mention the other tools: UI mode (--ui) for watching tests step by step, --debug with the inspector, and codegen for drafting locators, which you then clean up by hand.
Comparison questions
"Why Playwright over Selenium or Cypress?"
Give a balanced answer, because the interviewer's team may use another tool. Playwright: auto-waiting, browser contexts, several tabs and origins in one test, a built-in runner with tracing, and support for TypeScript, JavaScript, Python, Java and .NET. Selenium: the WebDriver standard, the widest language and grid ecosystem, and many existing suites. Cypress: a strong developer experience for front-end teams, running inside the browser, with more limits on tabs and origins. The comparison guide has the details. If you have migrated a suite from one tool to another, tell that story.
A practical task to rehearse
Many interviews include a short live exercise: "Write a test that searches for a product and checks the results." Practise it end to end:
- Navigate, using a
baseURLfrom config rather than a hard-coded host. - Use role-based locators.
- Assert with web-first assertions on the results, not on a count read once.
- Keep the test independent: no reliance on data another test created.
- Talk through what you would add next: a page object, test data set up through the API, and a negative case.
If you work in .NET, the guide to a first Playwright suite in C# walks through the same steps. For the questions every QA interview shares (test design, SQL, bug reports), see QA interview questions for remote roles.
The open roles below name Playwright.