These questions mirror real interviews: architecture and auto-waiting first, then locators and network mocking, then auth, parallelism, and CI. Practice explaining answers with a short code example, not just definitions.
How to Use These Questions
Read the quick-reference table for rapid review, then study the extended Q&A below for fuller answers you can adapt in your own words.
Interviewers often follow up with "given this code, will it flake?" — practice reasoning about await, expect() retries, and page.route() together.
// Common follow-up: will this flake if the API is slow?
await expect(page.getByRole('row')).toHaveCount(3);
Strong answer: expect() retries until three rows appear or timeout — no fixed sleep needed.
Cross-browser automation + test runner with auto-waiting
vs Selenium?
Modern protocol, built-in network routing, auto-wait, trace
What is page.route()?
Intercept/mock network requests from the browser
Why avoid waitForTimeout?
Guesses duration; use expect() or waitForURL
What is storageState?
Saved cookies/storage to skip repeated logins
Best locators?
getByRole → getByLabel → getByTestId
What are fixtures?
Injected deps: page, request, custom via test.extend
Trace Viewer?
Replay timeline of actions, network, DOM on failure
Fundamentals Interview Topics
Expect questions on browser contexts (isolation), auto-waiting (actionability checks), and how Playwright differs from in-browser tools like Cypress (multi-tab, out-of-process, WebKit).
Explain browser context vs browser vs page.
Describe what happens when you omit await.
Name the three shipped browser engines.
What does test.describe do?
Advanced Interview Topics
Senior roles add network mocking strategies, auth optimization with globalSetup, parallel sharding, and debugging CI-only failures with traces.
page.route vs request fixture — when to use each.
How storageState + globalSetup speed up suites.
Sharding and merge-reports in CI.
Fixing a flaky test — systematic approach.
Common Mistakes
Memorizing definitions without practicing small code examples.
Claiming Playwright is Chromium-only in interviews.
Unable to explain difference between page.route and request.get.
No story about debugging a real CI failure with Trace Viewer.
Key Takeaways
Combine definitions with tiny code examples in answers.
Cross-reference weak areas in earlier course lessons.
Pro Tip
End each answer with one sentence on trade-offs — interviewers notice when you understand limits, not just features.
Extended Playwright Interview Q&A
15 questions with fuller answers for interview preparation.
1. How does Playwright architecture differ from Selenium WebDriver?
Playwright uses a modern bidirectional browser protocol with persistent connections, auto-waiting, built-in page.route(), tracing, and isolated browser contexts. WebDriver sends one-way HTTP commands to a separate driver process and typically needs explicit waits and external tools for network control.
2. Explain Playwright auto-waiting.
Before actions and assertions, Playwright retries until elements are attached, visible, stable, enabled, and receiving events — or until timeout. expect() matchers similarly retry until they pass, tolerating async rendering without manual sleeps.
3. What locator priority does Playwright recommend?
getByRole(), then getByLabel(), getByPlaceholder(), getByTestId(), then text/CSS. Role locators align with accessibility and survive cosmetic CSS refactors.
4. Why is page.waitForTimeout() discouraged?
Fixed delays guess timing — too short stays flaky, too long wastes CI time. Prefer await expect(locator).toBeVisible(), page.waitForURL(), or page.waitForResponse().
5. How does page.route() differ from the request fixture?
page.route() intercepts requests made by the app in the browser — ideal for UI tests with mocked APIs. The request fixture makes direct HTTP calls from Node for API contract testing or setup.
6. What problem does storageState solve?
Repeating UI login in every test is slow and brittle. Save cookies/localStorage once via globalSetup and reuse with test.use({ storageState: 'auth.json' }).
7. What are Playwright fixtures?
Dependencies injected into tests — built-in page, context, browser, request. Extend with test.extend() for custom setup like admin pages or seeded data.
8. How does component testing differ from E2E?
Component tests mount isolated UI with @playwright/experimental-ct-* and the mount fixture. E2E drives the full app through page.goto() with real routing and backends (often stubbed).
9. Debug a test passing locally but failing in CI?
Compare env vars, baseURL, worker count, and timeouts. Download CI traces and screenshots. Look for order-dependent state exposed by parallel CI runs.
10. What causes flaky Playwright tests?
Missing await, waitForTimeout, shared mutable state, live variable APIs, ambiguous locators matching wrong elements. Fix with expect waits, page.route stubs, isolated contexts, and strict role locators.
11. Run tests across Chromium, Firefox, and WebKit?
Define multiple projects in playwright.config.ts with different browsers from the devices catalog. Run all or target with --project=firefox.
12. What is Trace Viewer?
Replays test timeline: actions, network, console, DOM snapshots. Enable with trace: 'on-first-retry'. Open via npx playwright show-trace trace.zip.
13. Test a protected route?
Use storageState for authenticated access tests. For anonymous redirect tests, goto the route without auth and await expect(page).toHaveURL(/login/).
14. Recommended CI setup?
npx playwright install --with-deps, health-check app start, run npx playwright test, upload HTML report and traces on failure, cache browsers between runs.
15. E2E vs API vs component test balance?
Many fast API and component tests, fewer E2E journeys for critical paths — testing pyramid balances speed and confidence.
Continue with Playwright Quiz to build on what you learned here.