Tracing
Record execution traces that capture DOM snapshots, screenshots, network activity, and console logs at every step.
Commands
playwright-cli tracing-start # start recording
playwright-cli tracing-stop # stop and save
Basic recording
playwright-cli tracing-start
playwright-cli goto https://example.com
playwright-cli click e5
playwright-cli fill e3 "test"
playwright-cli tracing-stop
Both commands print the paths they write to:
Trace recording stopped.
[Trace](.playwright-cli/traces/trace-1771097322679.trace)
[Network log](.playwright-cli/traces/trace-1771097322679.network)
[Resources](.playwright-cli/traces/resources)
The trace is written live — the file links appear as soon as tracing-start runs, so you can open
the viewer while the automation is still going.
| File | Contents |
|---|---|
trace-{timestamp}.trace | Actions, DOM snapshots before and after each one, screenshots, console messages, timing |
trace-{timestamp}.network | Every request and response, with headers, bodies and timing |
resources/ | Cached images, fonts, stylesheets and scripts needed to replay the page |
Viewing a trace
npx playwright show-trace .playwright-cli/traces/trace-1771097322679.trace
The Trace Viewer shows a timeline of every action with DOM snapshots (before and after), screenshots, network requests and responses, console messages, and timing.
Workflow: debugging a failing scenario
# Start tracing
playwright-cli tracing-start
# Walk through the failing flow
playwright-cli goto https://store.example.com/checkout
playwright-cli fill e10 "4111111111111111"
playwright-cli click e15
# Check what went wrong
playwright-cli snapshot
# - text: "Payment processing failed"
playwright-cli console error
# [ERROR] POST /api/payment 422: {"error":"Card number must include expiry"}
# Save trace for analysis
playwright-cli tracing-stop
Cleaning up
Traces can consume significant disk space:
find .playwright-cli/traces -mtime +7 -delete