| name | playwright-trace |
| description | Inspect Playwright trace files from the command line — list actions, view requests, console, errors, snapshots and screenshots. |
| allowed-tools | Bash(npx:*) |
Playwright Trace CLI
Inspect .zip trace files produced by Playwright tests without opening a browser.
Workflow
- Start with
trace open <trace.zip> to extract the trace and see its metadata.
- Use
trace actions to see all actions with their action IDs.
- Use
trace action <action-id> to drill into a specific action — see parameters, logs, source location, and available snapshots.
- Use
trace requests, trace console, or trace errors for cross-cutting views.
- Use
trace snapshot <action-id> to get the DOM snapshot, or run a browser command against it.
- Use
trace close to remove the extracted trace data when done.
All commands after open operate on the currently opened trace — no need to pass the trace file again. Opening a new trace replaces the previous one.
Commands
Open a trace
npx playwright trace open <trace.zip>
Close a trace
npx playwright trace close
Actions
npx playwright trace actions
npx playwright trace actions --grep "click"
npx playwright trace actions --errors-only
Action details
npx playwright trace action <action-id>
The action command displays available snapshot phases (before, input, after) and the exact command to extract them.
Requests
npx playwright trace requests
npx playwright trace requests --grep "api"
npx playwright trace requests --method POST
npx playwright trace requests --failed
Request details
npx playwright trace request <request-id>
Console
npx playwright trace console
npx playwright trace console --errors-only
npx playwright trace console --browser
npx playwright trace console --stdio
Errors
npx playwright trace errors
Snapshots
The snapshot command loads the DOM snapshot for an action into a headless browser and runs a single browser command against it. Without a browser command, it returns the accessibility snapshot.
npx playwright trace snapshot <action-id>
npx playwright trace snapshot <action-id> --name before
npx playwright trace snapshot <action-id> -- eval "document.title"
npx playwright trace snapshot <action-id> -- eval "document.querySelector('#error').textContent"
npx playwright trace snapshot <action-id> -- eval "el => el.getAttribute('data-testid')" e5
npx playwright trace snapshot <action-id> -- screenshot
npx playwright trace snapshot <action-id> -- eval "document.body.outerHTML" --filename=page.html
npx playwright trace snapshot <action-id> -- screenshot --filename=screenshot.png
Only three browser commands are useful on a frozen snapshot: snapshot, eval, and screenshot.
Attachments
npx playwright trace attachments
npx playwright trace attachment 1
npx playwright trace attachment 1 -o out.png
Typical investigation
npx playwright trace open test-results/my-test/trace.zip
npx playwright trace actions
npx playwright trace actions --errors-only
npx playwright trace action 12
npx playwright trace snapshot 12
npx playwright trace snapshot 12 -- eval "document.querySelector('.error-message').textContent"
npx playwright trace requests --failed
npx playwright trace console --errors-only