Testing / Playwright Interview questions
How do you debug a failing Playwright test?
Playwright provides several layered tools rather than forcing you to rely on console logs alone.
npx playwright test --debug # opens the Inspector, step-by-step npx playwright test --ui # opens the interactive UI mode npx playwright show-trace trace.zip # replays a recorded run
UI mode is often the fastest starting point - it lists tests, lets you run them individually, and shows a timeline with DOM snapshots for each step without needing a separate trace file. For failures that only happen on CI, enabling trace: 'on-first-retry' means you get a downloadable trace artifact to replay locally instead of trying to reproduce a flaky failure blind. Adding a temporary await page.pause() in the test code is another quick way to freeze execution at a specific line for manual inspection.
More Related questions...