Use Playwright Trace Viewer and built-in debugging tools to diagnose and fix flaky tests

domain: playwright.dev · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Enable tracing in `playwright.config.ts` by setting `use: { trace: 'on-first-retry' }` so a trace is captured automatically whenever a test fails and is retried.
  2. After a failing run, open the trace with `npx playwright show-trace path/to/trace.zip` — the Trace Viewer shows a timeline of actions, DOM snapshots before and after each step, network requests, and console logs.
  3. Use `npx playwright test --debug` to run a single test with the Playwright Inspector open; step through actions, observe the live browser, and use the locator picker to identify stable selectors.
  4. Add `await page.pause()` at any point in a test to halt execution and open the Inspector mid-test for interactive exploration.
  5. For flakiness caused by timing, check the action waterfall in the trace for long gaps between actions and correlate with the network panel to find slow API responses; then add explicit `waitForResponse` or assertion retries rather than `waitForTimeout`.

Known gotchas

Related routes

Debug a CI-only Playwright test failure by capturing and inspecting a trace.zip in Trace Viewer
playwright.dev · 5 steps · unrated
Use the Playwright --ui flag to interactively watch, debug, and re-run tests during development
playwright.dev · 6 steps · unrated
Capture and inspect a Playwright trace from a Robot Framework Browser library test suite
robotframework-browser.org · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans