| name | playwright-trace |
| description | Inspect Playwright trace files from the command line — list actions, view requests, console, errors, snapshots and screenshots. |
| allowed-tools | Bash(playwright:*),Bash(npx:*) |
Playwright Trace CLI
Inspect .zip trace files produced by Playwright tests without opening a browser.
playwright is installed globally at /usr/bin/playwright in the sandbox — use it directly (fallback on npx when needed). The harness sets PLAYWRIGHT_BROWSERS_PATH=/tmp/playwright-browsers which points to pre-installed Chromium for trace snapshot.
Use playwright trace <cmd> for everything below. Fall back to playwright trace <cmd> only if the global binary is unavailable.
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
playwright trace open <trace.zip>
Close a trace
playwright trace close
Actions
playwright trace actions
playwright trace actions --grep "click"
playwright trace actions --errors-only
Action details
playwright trace action <action-id>
The action command displays available snapshot phases (before, input, after) and the exact command to extract them.
Requests
playwright trace requests
playwright trace requests --grep "api"
playwright trace requests --method POST
playwright trace requests --failed
Request details
playwright trace request <request-id>
Console
playwright trace console
playwright trace console --errors-only
playwright trace console --browser
playwright trace console --stdio
Errors
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.
playwright trace snapshot <action-id>
playwright trace snapshot <action-id> --name before
playwright trace snapshot <action-id> -- eval "document.title"
playwright trace snapshot <action-id> -- eval "document.querySelector('#error').textContent"
playwright trace snapshot <action-id> -- eval "el => el.getAttribute('data-testid')" e5
playwright trace snapshot <action-id> -- screenshot
playwright trace snapshot <action-id> -- eval "document.body.outerHTML" --filename=page.html
playwright trace snapshot <action-id> -- screenshot --filename=screenshot.png
Only three browser commands are useful on a frozen snapshot: snapshot, eval, and screenshot.
Attachments
playwright trace attachments
playwright trace attachment 1
playwright trace attachment 1 -o out.png
Typical investigation
playwright trace open test-results/my-test/trace.zip
playwright trace actions
playwright trace actions --errors-only
playwright trace action 12
playwright trace snapshot 12
playwright trace snapshot 12 -- eval "document.querySelector('.error-message').textContent"
playwright trace requests --failed
playwright trace console --errors-only