{"data":{"slug":"github-microsoft-playwright-packages-playwright-core-src-tools-skills-playwright-trace-65c3269be793","title":"Analyze Playwright Trace Files","summary":"Use the Playwright CLI to inspect trace files, debug test failures, analyze network requests, and examine DOM snapshots without launching a browser. The process involves extracting trace data, viewing actions, requests, console logs, and snapshots, and closing the trace when done.","url":"https:\/\/skillshunter.net\/skills\/github-microsoft-playwright-packages-playwright-core-src-tools-skills-playwright-trace-65c3269be793","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-microsoft-playwright-packages-playwright-core-src-tools-skills-playwright-trace-65c3269be793","markdown_url":"https:\/\/skillshunter.net\/skills\/github-microsoft-playwright-packages-playwright-core-src-tools-skills-playwright-trace-65c3269be793.md","download_url":"https:\/\/skillshunter.net\/skills\/github-microsoft-playwright-packages-playwright-core-src-tools-skills-playwright-trace-65c3269be793\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Before using the CLI, ensure the trace file is in `.zip` format and extracted using `trace open <trace.zip>`. The `trace` commands operate on the currently opened trace, and opening a new trace replaces the previous one.","instructions":"---\nname: playwright-trace\ndescription: Inspect Playwright trace files from the command line \u2014 list actions, view requests, console, errors, snapshots and screenshots.\nallowed-tools: Bash(npx playwright trace:*)\n---\n\n# Playwright Trace CLI\n\nInspect `.zip` trace files produced by Playwright tests without opening a browser.\n\n## Workflow\n\n1. Start with `trace open <trace.zip>` to extract the trace and see its metadata.\n2. Use `trace actions` to see all actions with their action IDs.\n3. Use `trace action <action-id>` to drill into a specific action \u2014 see parameters, logs, source location, and available snapshots.\n4. Use `trace requests`, `trace console`, or `trace errors` for cross-cutting views.\n5. Use `trace snapshot <action-id>` to get the DOM snapshot, or run a browser command against it.\n6. Use `trace close` to remove the extracted trace data when done.\n\nAll commands after `open` operate on the currently opened trace \u2014 no need to pass the trace file again. Opening a new trace replaces the previous one.\n\n## Commands\n\n### Open a trace\n\n```bash\n# Extract trace and show metadata: browser, viewport, duration, action\/error counts\nnpx playwright trace open <trace.zip>\n```\n\n### Close a trace\n\n```bash\n# Remove extracted trace data\nnpx playwright trace close\n```\n\n### Actions\n\n```bash\n# List all actions as a tree with action IDs and timing\nnpx playwright trace actions\n\n# Filter by action title (regex, case-insensitive)\nnpx playwright trace actions --grep \"click\"\n\n# Only failed actions\nnpx playwright trace actions --errors-only\n```\n\n### Action details\n\n```bash\n# Show full details for one action: params, result, logs, source, snapshots\nnpx playwright trace action <action-id>\n```\n\nThe `action` command displays available snapshot phases (before, action, after) and the exact command to extract them.\n\n### Requests\n\n```bash\n# All network requests: start time (on the `trace actions` clock), method, status, URL, duration, size\nnpx playwright trace requests\n\n# Filter by URL pattern\nnpx playwright trace requests --grep \"api\"\n\n# Filter by HTTP method\nnpx playwright trace requests --method POST\n\n# Only failed requests (status >= 400)\nnpx playwright trace requests --failed\n```\n\n### Request details\n\n```bash\n# Show full details for one request: headers, body, security\nnpx playwright trace request <request-id>\n```\n\n### Console\n\n```bash\n# All console messages and stdout\/stderr\nnpx playwright trace console\n\n# Only errors\nnpx playwright trace console --errors-only\n\n# Only browser console (no stdout\/stderr)\nnpx playwright trace console --browser\n\n# Only stdout\/stderr (no browser console)\nnpx playwright trace console --stdio\n\n# Filter by message text pattern\nnpx playwright trace console --grep \"failed to fetch\"\n```\n\n### Errors\n\n```bash\n# All errors with stack traces and associated actions\nnpx playwright trace errors\n```\n\n### Snapshots\n\nThe `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.\n\n```bash\n# Get the accessibility snapshot (default)\nnpx playwright trace snapshot <action-id>\n\n# Use a specific phase\nnpx playwright trace snapshot <action-id> --phase before\n\n# Run eval to query the DOM\nnpx playwright trace snapshot <action-id> -- eval \"document.title\"\nnpx playwright trace snapshot <action-id> -- eval \"document.querySelector('#error').textContent\"\n\n# Eval on a specific element ref (from the snapshot)\nnpx playwright trace snapshot <action-id> -- eval \"el => el.getAttribute('data-testid')\" e5\n\n# Take a screenshot of the snapshot\nnpx playwright trace snapshot <action-id> -- screenshot\n\n# Redirect output to a file\nnpx playwright trace snapshot <action-id> -- eval \"document.body.outerHTML\" --filename=page.html\nnpx playwright trace snapshot <action-id> -- screenshot --filename=screenshot.png\n```\n\nOnly three browser commands are useful on a frozen snapshot: `snapshot`, `eval`, and `screenshot`.\n\n### Attachments\n\n```bash\n# List all trace attachments\nnpx playwright trace attachments\n\n# Extract an attachment by its number\nnpx playwright trace attachment 1\nnpx playwright trace attachment 1 -o out.png\n```\n\n## Typical investigation\n\n```bash\n# 1. Open the trace and see what's inside\nnpx playwright trace open test-results\/my-test\/trace.zip\n\n# 2. What actions ran?\nnpx playwright trace actions\n\n# 3. Which action failed?\nnpx playwright trace actions --errors-only\n\n# 4. What went wrong?\nnpx playwright trace action 12\n\n# 5. What did the page look like at that moment?\nnpx playwright trace snapshot 12\n\n# 6. Query the DOM for more detail\nnpx playwright trace snapshot 12 -- eval \"document.querySelector('.error-message').textContent\"\n\n# 7. Any relevant network failures?\nnpx playwright trace requests --failed\n\n# 8. Any console errors?\nnpx playwright trace console --errors-only\n```\n","use_cases":["Debugging test failures by examining action logs and errors","Analyzing network requests and responses for performance issues","Inspecting DOM snapshots to understand the state of a page at a specific action"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/microsoft\/playwright\/blob\/b4d016aadc5cbd2b898a284307975fe73e05483d\/packages\/playwright-core\/src\/tools\/skills\/playwright-trace\/SKILL.md","source_commit":"b4d016aadc5cbd2b898a284307975fe73e05483d","license":null,"version":null,"listing_approved_at":"2026-11-21","created_at":"2026-11-20T13:37:37.000000Z","updated_at":"2026-11-21T09:43:53.000000Z","seo_title":"Analyze Playwright Trace Files CLI","seo_description":"Use the Playwright CLI to inspect trace files, debug test failures, and analyze network requests and DOM snapshots.","seo_keywords":["Playwright trace analysis","Debug Playwright tests","Inspect trace files","Analyze network requests","DOM snapshot inspection"]}}