Playwright Senior interview questions and answers
77 questions for a Playwright (Senior) interview - with correct answers, explanations and links to the docs.
Take this quiz- 1.A Playwright suite takes 50 minutes in CI. What is usually the most effective first step?
- 2.How does
--shard=2/4split the work? - 3.Why does
fullyParallelhelp balance shards? - 4.How do you get one report from four sharded CI jobs?
- 5.What does
--only-changeddo? - 6.What does
maxFailuresin the config help with? - 7.What does
globalTimeoutlimit? - 8.Why should E2E tests not try to cover every business rule?
- 9.How do you decide which flows deserve E2E tests?
- 10.How would you design fixtures for a pool of test accounts in parallel runs?
- 11.Why can a saved
storageStatemake tests fail days later? - 12.How do you test an app that logs in through an external SSO provider?
- 13.How can E2E tests handle two-factor authentication with a TOTP app?
- 14.How do you test a flow that sends a confirmation email?
- 15.Mocking all APIs makes E2E tests fast. What is the main risk?
- 16.How do you keep HAR-based mocks from going stale?
- 17.Why might
page.routenot catch some requests? - 18.How do you mock a WebSocket server in a Playwright test?
- 19.What are the limits of mobile emulation in Playwright?
- 20.A test passes in Chromium but fails in WebKit. What is a sensible approach?
- 21.Why can headless and headed runs behave differently?
- 22.How do you debug a failure that happens only in CI?
- 23.Which pattern often causes flaky tests after a click that navigates?
- 24.Why can typing into a debounced search field cause flaky results?
- 25.Why might a click land on the wrong item in a list that animates in?
- 26.How do you measure flakiness across a suite over time?
- 27.What should happen to a test that flakes often?
- 28.What is the trade-off of sharing one page across tests with a worker-scoped fixture?
- 29.Why are browser contexts cheap compared with launching browsers?
- 30.How do you add a custom matcher like
toHaveCartTotal? - 31.What does
expect.configure({ timeout: 15_000 })give you? - 32.When would you write a custom reporter?
- 33.What does
box: trueon atest.stepdo? - 34.How can a fixture fail tests that print console errors?
- 35.Where should a test write temporary files so parallel tests don't clash?
- 36.What is the main maintenance problem of a huge "god" page object?
- 37.What is an alternative to deep page object inheritance?
- 38.How should locators be chosen in an app with several languages?
- 39.What should a team policy on
data-testidsay? - 40.When is it reasonable to seed data directly in the database?
- 41.How do you clean up data created by E2E tests?
- 42.Why run E2E tests against preview deployments of each pull request?
- 43.What is a good use of Playwright tests against production?
- 44.Why is Playwright a poor tool for load testing?
- 45.How can Playwright collect performance data for a page?
- 46.What is the trade-off of using CDP sessions in Playwright tests?
- 47.What are the limits of Playwright component testing?
- 48.When does visual regression testing pay off?
- 49.How do you make screenshot tests stable across machines?
- 50.What does
toHaveScreenshotdo to reduce flakiness before comparing? - 51.What are Playwright test agents?
- 52.What is the main risk of letting an AI agent "heal" failing tests?
- 53.What are the limits of code recorded with
codegen? - 54.How do you run Playwright for several apps in a monorepo?
- 55.How do you start several services before tests?
- 56.How would you test a payment flow in E2E?
- 57.Why might
page.waitForURLbe needed after a form submit? - 58.How should a team handle tests that need many minutes, like big imports?
- 59.What does a nightly full run add to PR runs of a smaller subset?
- 60.How do you check that every route has no serious accessibility violations?
- 61.What does
page.clock.install()let you test that real timers make impractical? - 62.How do you test an Electron app with Playwright?
- 63.Why should fixtures not hide the main action of a test?
- 64.What is a reasonable policy for
test.skipandfixmein a large suite? - 65.Why keep trace files small in big suites?
- 66.How do you make sure tests don't depend on run order?
- 67.What should you check first when a test times out on
click()? - 68.How do you test that a feature behind a flag works in both states?
- 69.Why may tests that pass with one worker fail with many?
- 70.How should E2E test code be reviewed?
- 71.What is the purpose of
test.info().annotations? - 72.Why should a large suite avoid
beforeAllthat creates shared state for a file? - 73.How do you handle third-party scripts like chat widgets that slow tests?
- 74.What is the main benefit of running each locale or tenant as a Playwright project?
- 75.When is checking the network layer in E2E tests better than checking the UI?
- 76.What makes a good E2E failure message for the team?
- 77.What is the role of Playwright in a test strategy alongside unit and API tests?