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