Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Drive a browser from the terminal with Playwright snapshots, refs, and direct page actions.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/tracing.md
1# Tracing23Capture detailed execution traces for debugging and analysis. Traces include DOM snapshots, screenshots, network activity, and console logs.45## Basic Usage67```bash8# Start trace recording9playwright-cli tracing-start1011# Perform actions12playwright-cli open https://example.com13playwright-cli click e114playwright-cli fill e2 "test"1516# Stop trace recording17playwright-cli tracing-stop18```1920## Trace Output Files2122When you start tracing, Playwright creates a `traces/` directory with several files:2324### `trace-{timestamp}.trace`2526**Action log** - The main trace file containing:27- Every action performed (clicks, fills, navigations)28- DOM snapshots before and after each action29- Screenshots at each step30- Timing information31- Console messages32- Source locations3334### `trace-{timestamp}.network`3536**Network log** - Complete network activity:37- All HTTP requests and responses38- Request headers and bodies39- Response headers and bodies40- Timing (DNS, connect, TLS, TTFB, download)41- Resource sizes42- Failed requests and errors4344### `resources/`4546**Resources directory** - Cached resources:47- Images, fonts, stylesheets, scripts48- Response bodies for replay49- Assets needed to reconstruct page state5051## What Traces Capture5253| Category | Details |54|----------|---------|55| **Actions** | Clicks, fills, hovers, keyboard input, navigations |56| **DOM** | Full DOM snapshot before/after each action |57| **Screenshots** | Visual state at each step |58| **Network** | All requests, responses, headers, bodies, timing |59| **Console** | All console.log, warn, error messages |60| **Timing** | Precise timing for each operation |6162## Use Cases6364### Debugging Failed Actions6566```bash67playwright-cli tracing-start68playwright-cli open https://app.example.com6970# This click fails - why?71playwright-cli click e57273playwright-cli tracing-stop74# Open trace to see DOM state when click was attempted75```7677### Analyzing Performance7879```bash80playwright-cli tracing-start81playwright-cli open https://slow-site.com82playwright-cli tracing-stop8384# View network waterfall to identify slow resources85```8687### Capturing Evidence8889```bash90# Record a complete user flow for documentation91playwright-cli tracing-start9293playwright-cli open https://app.example.com/checkout94playwright-cli fill e1 "4111111111111111"95playwright-cli fill e2 "12/25"96playwright-cli fill e3 "123"97playwright-cli click e49899playwright-cli tracing-stop100# Trace shows exact sequence of events101```102103## Trace vs Video vs Screenshot104105| Feature | Trace | Video | Screenshot |106|---------|-------|-------|------------|107| **Format** | .trace file | .webm video | .png/.jpeg image |108| **DOM inspection** | Yes | No | No |109| **Network details** | Yes | No | No |110| **Step-by-step replay** | Yes | Continuous | Single frame |111| **File size** | Medium | Large | Small |112| **Best for** | Debugging | Demos | Quick capture |113114## Best Practices115116### 1. Start Tracing Before the Problem117118```bash119# Trace the entire flow, not just the failing step120playwright-cli tracing-start121playwright-cli open https://example.com122# ... all steps leading to the issue ...123playwright-cli tracing-stop124```125126### 2. Clean Up Old Traces127128Traces can consume significant disk space:129130```bash131# Remove traces older than 7 days132find .playwright-cli/traces -mtime +7 -delete133```134135## Limitations136137- Traces add overhead to automation138- Large traces can consume significant disk space139- Some dynamic content may not replay perfectly140