Playwright interview questions test browser automation skill across locators, auto-waiting, assertions, browser contexts, fixtures, traces, parallel runs, and CI debugging.
45 questions with answersKey Takeaways
Playwright is a testing framework for automating modern web apps across Chromium, Firefox, and WebKit. It is commonly used with TypeScript or JavaScript, but also supports Python, Java, and .NET. In interviews, Playwright questions check whether you can write stable browser tests, isolate state with contexts, debug failures with traces, and run suites in CI without hiding flaky behavior.
Watch: Get started with end to end testing: Playwright
Video: Get started with end to end testing: Playwright (Microsoft Developer, YouTube)
Test yourself and earn a certificate
6 quick questions. Score 70%+ to download your Playwright certificate.
Start here. These are the definitions and first-principle checks that open most rounds.
Playwright is used for browser automation and web app testing across Chromium, Firefox, and WebKit.
It supports TypeScript, JavaScript, Python, Java, and .NET.
Playwright changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Watch a deeper explanation
Video: Playwright Automation Tutorial for Beginners (LambdaTest, YouTube)
A browser object represents a launched browser engine instance.
It can create isolated browser contexts.
browser changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
A browser context is an isolated browser session with its own cookies, storage, permissions, and pages.
Contexts help run tests independently.
browser context changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
A page represents a single browser tab or page inside a context.
Most user actions and assertions happen through page or locator objects.
page changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
| Answer part | What to say | Evidence to mention |
|---|---|---|
| Definition | page in one direct sentence. | Official docs or course material |
| Use case | The work where it changes a decision. | Dataset, model, query, dashboard, or pipeline |
| Risk | What breaks when it is misunderstood. | Metric, log, test result, or review note |
A locator finds elements and performs actions with built-in waiting and retry behavior.
Prefer user-facing locators before brittle CSS or XPath.
locator changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Watch a deeper explanation
Video: Playwright Beginner Tutorial (Automation Step by Step, YouTube)
getByRole locates elements by accessible role and name.
It aligns tests with how users and assistive technology understand the page.
getByRole changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Playwright waits for elements to be actionable before actions such as click or fill.
It checks visibility, stability, enabled state, and event receiving where relevant.
auto-waiting changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Actionability flow
Expect assertions wait for expected UI or state conditions before failing.
They reduce manual waiting and make intent clear.
expect assertions changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Fixtures provide reusable setup and teardown for tests.
They can create pages, data, logged-in state, or services.
fixtures changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Projects define different test configurations such as browser, viewport, locale, or device.
They make cross-browser and mobile viewport runs manageable.
projects changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Storage state stores cookies and local storage for reuse across tests.
It is commonly used to avoid logging in through UI for every test.
storage state changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Trace viewer shows actions, snapshots, network, console, and timing from a test run.
It is one of the best artifacts for CI failure triage.
trace viewer changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
APIRequestContext sends API requests from Playwright tests.
It is useful for setup, teardown, and API assertions.
APIRequestContext changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Watch a deeper explanation
Video: Playwright Automation Using TypeScript (The Testing Academy, YouTube)
Playwright Test can run files or tests across workers based on configuration.
Parallel tests need isolated data and state.
parallel execution changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Use code generation as a starting point, then clean locators, assertions, and test structure.
Generated code is not final test design.
test generator changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
These questions test whether you can apply the topic to real data, real code, and messy constraints.
Open login, fill fields using labels, submit, then assert a logged-in signal.
Use role and label locators where possible.
write login test changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
await page.goto('/login');
await page.getByLabel('Email').fill('qa@example.com');
await page.getByLabel('Password').fill('secret');
await page.getByRole('button', { name: 'Sign in' }).click();
await expect(page.getByText('Dashboard')).toBeVisible();role, label, placeholder, text, alt text, title, or test ID based on user intent comes first.
Use CSS or XPath only when user-facing locators are not practical.
choose locators changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Create authenticated storage state once, then reuse it in relevant projects or setup.
Keep at least one test for the actual login flow.
use storage state changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Use fixtures for reusable setup such as test data, authenticated page, API client, or cleanup.
Fixtures should make dependencies explicit.
set up fixtures changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Use route handling to fulfill a request with controlled response data.
Mock only when the goal is UI behavior, not backend integration.
mock network changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Use locator assertions, action auto-waiting, or specific events instead of arbitrary time waits.
Wait for the state that matters.
wait correctly changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Define projects for Chromium, Firefox, and WebKit, then choose which suites need all projects.
Not every low-risk test needs every browser.
run cross-browser changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Open the trace, inspect action timeline, DOM snapshot, console, network, screenshots, and error location.
Trace evidence is stronger than guessing.
debug with trace changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Create data through API, then use the UI only for the behavior under test.
This reduces test time and flake.
test API setup changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Use file chooser or setInputFiles, then assert upload success, validation, or preview.
Use small known test files.
handle file upload changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Watch a deeper explanation
Video: Playwright Testing Agents (Microsoft Developer, YouTube)
Register a dialog handler before the action that opens the dialog, then accept, dismiss, or assert its message.
Handlers must be set before the dialog appears.
handle dialogs changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Use device projects or viewport settings and assert responsive behavior.
Viewport tests are not the same as native mobile app tests.
test mobile viewport changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Check locator stability, assertion quality, data isolation, fixture clarity, runtime, and artifact configuration.
Test code should be reviewed like product code.
review test code changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Use stable locators, isolated data, proper assertions, traces, controlled environment, and avoid shared state.
Retries should not hide root causes.
reduce flake changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Advanced rounds test trade-offs, failure modes, and whether the decision can hold up under production pressure.
Locator strictness can fail because the target is ambiguous.
Refine the locator by role name, scope, filter, or test ID.
strict mode failure changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Check browser-specific behavior, CSS, timing, feature support, and whether the product supports that browser.
Cross-browser failures need product context.
works in Chromium only changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Replace generated selectors with role, label, text, or test ID locators.
Codegen is a draft.
codegen XPath changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Configure trace on retry or on failure, plus screenshot, video, and HTML report artifacts.
Failure evidence is part of framework quality.
no trace in CI changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Yes if the test is not about that setup path, but keep separate UI coverage for critical setup behavior.
Use the right layer for the goal.
API setup hides bug changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Check whether the UI has proper loading state, timeout, backend issue, test data, or environment instability.
Slow network may reveal product risk.
flaky network changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Tests become slower and harder to reason about.
Setup should be close to what the test needs.
overbroad beforeEach changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Retries are acceptable for known infrastructure noise, but every retry should be visible and tracked.
Retries are not a substitute for fixing flake.
retry policy changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Test intent becomes hard to read and failures are harder to diagnose.
Keep business assertions visible.
page object bloat changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Wait for the download event, trigger the action, then assert filename or saved content where useful.
Avoid relying only on button click.
download test changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Wait for the page event on the context while triggering the action, then assert the new page.
Set the wait before the action.
new tab flow changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Move setup to API, reduce duplicate UI paths, split smoke from regression, parallelize safely, and remove weak checks.
Speed must not reduce trust.
slow suite changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
It explains locators, actionability, fixtures, contexts, traces, parallel isolation, and when to test below the UI.
Senior candidates design for trust and maintenance.
senior Playwright answer changes Playwright decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Playwright, Cypress, and Selenium can all test web apps, but they make different trade-offs around browser support, language support, debugging, and framework design.
| Tool | Strong fit | Interview strength | Watch out |
|---|---|---|---|
| Playwright | Modern cross-browser web automation | Auto-waiting, contexts, traces, API setup | Requires good fixture and project setup |
| Cypress | JavaScript front-end teams | Runner feedback and network stubbing | Cross-browser and multi-tab constraints matter |
| Selenium | Enterprise suites and wide language support | Mature ecosystem | More manual framework choices |
| API tests | Fast backend checks | Stable setup and business rules | No browser rendering proof |
Playwright interview topic weight
Most Playwright screens are practical coding plus debugging questions.
Scale: Hyring editorial score for interview preparation, not an external benchmark.
Prepare with one small TypeScript suite: login, a list page, one API setup, one mocked response, and one trace-based failure debug.
Playwright test design flow
Stable Playwright tests usually stable locators and isolated state comes first.
Strong Playwright answers show that you can write tests like maintainable code. The test should be readable, isolated, and debuggable.
| Topic | Weak answer | Strong answer |
|---|---|---|
| Locators | I use XPath. | I role, label, text, or test ID that matches user intent comes first. |
| State | Tests share one browser session. | I use contexts, fixtures, and storage state intentionally. |
| Debugging | I rerun until it passes. | I inspect trace, screenshot, video, console, and network. |
| Cross-browser | Run everything everywhere. | Run critical paths across engines and full regression where risk justifies it. |
6 questions, about 4 minutes. Score 70% or higher to earn a shareable certificate.
Hyring's AI Coding Interviewer can score test code and reasoning together. Use this page to practice locators, fixtures, traces, and CI failure stories before a live automation screen.
Try AI coding interview prep