Documentation Index
Fetch the complete documentation index at: https://mintlify.com/microsoft/playwright/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Trace Viewer is a post-mortem debugging tool that allows you to explore a recorded trace of your test execution. It captures everything: actions, screenshots, network requests, console logs, and more. Unlike the Inspector which debugs live execution, Trace Viewer analyzes what already happened.Recording Traces
During Test Execution
Enable tracing in your Playwright config:playwright.config.ts
Trace Modes
Via Command Line
Override config settings:In Test Code
Programmatically control tracing:Opening Traces
Show Trace Command
The primary way to view traces:- Drag and drop trace files
- Paste trace URLs
- Browse to trace files
With Trace File
With Trace URL
Serve Trace on Network
Open trace in a browser tab:Browser Selection
chromium(default)firefoxorffwebkitorwk
Trace Viewer Interface
The Trace Viewer provides a comprehensive timeline view:Action Timeline
Left sidebar showing all actions:- Navigation events
- Clicks and inputs
- Assertions
- API calls
- Waits and timeouts
- Duration
- Success/failure status
- Associated logs
Action Details
Click any action to see:- Action
- Before/After
- Console
- Network
- Source
- Method called (e.g.,
page.click()) - Selector used
- Parameters passed
- Stack trace
- Source code location
Metadata Panel
Top section shows:- Test name and file
- Browser and platform
- Duration and status
- Retry attempt number
Advanced Trace Features
Filtering Actions
Use the filter box to find specific actions:Snapshots and Screenshots
The Trace Viewer captures:- Before snapshot: DOM state before each action
- After snapshot: DOM state after each action
- Screenshots: Visual representation at each step
Snapshots are interactive - you can click elements to copy selectors and explore the DOM.
Network Tab Analysis
Investigate network issues:- Open the Network tab
- See all requests with timing
- Check for failed requests (red)
- Inspect request/response data
Console Logs
All browser console output is captured:Trace Implementation Details
Based on/home/daytona/workspace/source/packages/playwright-core/src/server/trace/viewer/traceViewer.ts:154, the trace viewer:
- Starts an HTTP server to serve trace files
- Validates trace paths - supports local files, directories, and URLs
- Synthesizes trace descriptors for directory-based traces
- Launches a browser (or uses an existing one) to display the UI
- Routes trace file requests through the server
- Handles live trace updates when
--stdinflag is used
Trace File Formats
Traces can be:- ZIP files (
.zip) - Standard format containing all trace data - JSON files (
.json) - Trace manifest/descriptor - Directories - Unzipped trace with multiple files
Using Traces in CI/CD
Playwright Cloud
Storing Artifacts
playwright.config.ts
GitHub Actions Example
.github/workflows/tests.yml
Performance Considerations
Optimizing Trace Size
Trace Viewer Options
| Option | Description |
|---|---|
--browser, -b | Browser to use (chromium, firefox, webkit) |
--host, -h | Host to serve trace on (opens in browser tab) |
--port, -p | Port to serve trace on |
--stdin | Accept trace URLs over stdin to update viewer |
Example Workflows
Debug Failed CI Test
Compare Before/After
Share Traces
See Also
- Inspector - Debug tests interactively
- UI Mode - Watch tests run with live tracing
- Code Generator - Generate test code from actions
