New to Claude Skills? Learn how to install them →

microsoft on GitHub

Playwright Trace CLI

OfficialFree

Inspect Playwright trace files directly from the command line.

by microsoft94.3k stars on microsoft/playwright
3 views
Updated Aug 10, 2026
Get this skill

Free · Opens the source repo

What Playwright Trace CLI does

The Playwright Trace CLI is a command-line tool designed for developers who utilize Playwright for end-to-end testing. This skill enables users to inspect .zip trace files generated by Playwright tests without needing to launch a browser. By providing a straightforward interface, it allows for efficient analysis of test actions, network requests, console messages, and errors, all from the terminal.

To get started, users can open a trace file using the trace open command, which extracts the trace data and displays essential metadata such as browser type, viewport size, and action/error counts. Once the trace is open, various commands can be employed to delve deeper into the test execution. For example, trace actions lists all actions performed during the test, while trace requests provides insights into network interactions, including HTTP methods and response statuses.

The tool also supports detailed examination of individual actions and requests. Users can retrieve specific action details using trace action <action-id>, which reveals parameters, logs, and associated snapshots. This feature is particularly useful for debugging failed actions, as it allows developers to pinpoint issues within their test scripts. Additionally, the snapshot functionality enables users to capture the DOM state at any given action, facilitating further investigation into UI issues.

Overall, the Playwright Trace CLI is a valuable asset for developers looking to streamline their testing workflows and gain deeper insights into Playwright test executions. It is especially beneficial for those who prefer command-line interfaces over graphical tools, enabling quick access to trace data and enhancing debugging efficiency.

When to use it

Use this tool when you need to analyze Playwright trace files and troubleshoot test failures without a graphical interface.

When not to use it

This skill is not suitable for users who prefer a GUI for inspecting test results or those who do not utilize Playwright for testing.

What you can build with it

Debugging Failed Tests

Quickly identify which actions failed during a Playwright test run by using the `trace actions --errors-only` command.

Inspecting Network Requests

Analyze all network requests made during a test by running `trace requests`, allowing you to filter by method or status.

Viewing Console Messages

Retrieve all console messages, including errors, using the `trace console` command to help diagnose issues in your tests.

How to install Playwright Trace CLI

View source

1. Install with the skills CLI

npx skills add microsoft/playwright/playwright-trace --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by microsoft

Playwright Trace CLI

Inspect .zip trace files produced by Playwright tests without opening a browser.

Workflow

  1. Start with trace open <trace.zip> to extract the trace and see its metadata.
  2. Use trace actions to see all actions with their action IDs.
  3. Use trace action <action-id> to drill into a specific action — see parameters, logs, source location, and available snapshots.
  4. Use trace requests, trace console, or trace errors for cross-cutting views.
  5. Use trace snapshot <action-id> to get the DOM snapshot, or run a browser command against it.
  6. 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

# Extract trace and show metadata: browser, viewport, duration, action/error counts
npx playwright trace open <trace.zip>

Close a trace

# Remove extracted trace data
npx playwright trace close

Actions

# List all actions as a tree with action IDs and timing
npx playwright trace actions

# Filter by action title (regex, case-insensitive)
npx playwright trace actions --grep "click"

# Only failed actions
npx playwright trace actions --errors-only

Action details

# Show full details for one action: params, result, logs, source, snapshots
npx playwright trace action <action-id>

The action command displays available snapshot phases (before, input, after) and the exact command to extract them.

Requests

# All network requests: method, status, URL, duration, size
npx playwright trace requests

# Filter by URL pattern
npx playwright trace requests --grep "api"

# Filter by HTTP method
npx playwright trace requests --method POST

# Only failed requests (status >= 400)
npx playwright trace requests --failed

Request details

# Show full details for one request: headers, body, security
npx playwright trace request <request-id>

Console

# All console messages and stdout/stderr
npx playwright trace console

# Only errors
npx playwright trace console --errors-only

# Only browser console (no stdout/stderr)
npx playwright trace console --browser

# Only stdout/stderr (no browser console)
npx playwright trace console --stdio

Errors

# All errors with stack traces and associated actions
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.

# Get the accessibility snapshot (default)
npx playwright trace snapshot <action-id>

# Use a specific phase
npx playwright trace snapshot <action-id> --name before

# Run eval to query the DOM
npx playwright trace snapshot <action-id> -- eval "document.title"
npx playwright trace snapshot <action-id> -- eval "document.querySelector('#error').textContent"

# Eval on a specific element ref (from the snapshot)
npx playwright trace snapshot <action-id> -- eval "el => el.getAttribute('data-testid')" e5

# Take a screenshot of the snapshot
npx playwright trace snapshot <action-id> -- screenshot

# Redirect output to a file
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

# List all trace attachments
npx playwright trace attachments

# Extract an attachment by its number
npx playwright trace attachment 1
npx playwright trace attachment 1 -o out.png

Typical investigation

# 1. Open the trace and see what's inside
npx playwright trace open test-results/my-test/trace.zip

# 2. What actions ran?
npx playwright trace actions

# 3. Which action failed?
npx playwright trace actions --errors-only

# 4. What went wrong?
npx playwright trace action 12

# 5. What did the page look like at that moment?
npx playwright trace snapshot 12

# 6. Query the DOM for more detail
npx playwright trace snapshot 12 -- eval "document.querySelector('.error-message').textContent"

# 7. Any relevant network failures?
npx playwright trace requests --failed

# 8. Any console errors?
npx playwright trace console --errors-only

Frequently asked questions about Playwright Trace CLI

Similar skills