What a trace contains#
A trace is a zip file written by context.tracing.stop({ path }). We recorded one with Playwright 1.63 against a local fixture and unzipped it:
trace.trace actions, console messages and DOM snapshots
trace.network requests and responses with their headers
trace.stacks source locations of each action
resources/ response bodies and screenshots
screencast/ the screencast frames
The trace viewer shows each action with the page before and after it, the requests made during it and the console messages logged. Open it with npx playwright show-trace trace.zip, or drop it onto trace.playwright.dev, which Playwright's documentation describes as loading the trace in your browser without sending it to a server. Playwright: Trace viewer
DOM snapshots in a trace record more than a saved page does. In our fixture, text typed into an input and the content of an open shadow root both appeared in trace.trace. Neither appeared in the page's outerHTML or in a Chrome MHTML snapshot. See Send the page's DOM for that comparison.
Record a trace of the failing steps#
If the reproduction is already a Playwright test, run it with tracing on:
npx playwright test repro.spec.ts --trace on
For a manual reproduction, a short script records a trace while you click through by hand in a visible browser:
import { chromium } from 'playwright';
const browser = await chromium.launch({ headless: false });
const context = await browser.newContext();
await context.tracing.start({ screenshots: true, snapshots: true, sources: true });
const page = await context.newPage();
await page.goto('https://staging.example.test/orders');
await page.pause(); // reproduce by hand, then press Resume in the inspector
await context.tracing.stop({ path: 'trace.zip' });
await browser.close();
Trace or video#
| The maintainer needs to know | Send |
|---|---|
| The order of visible events, an animation or a layout jump | A video, or the trace's screencast |
| Which request ran at the click, and what it returned | A trace |
| What the DOM held when the wrong thing rendered | A trace |
| What the console printed, in order with the actions | A trace |
| Whether it happens in the reporter's own browser profile with extensions | A video or a Recorder flow, since Playwright starts a clean profile by default |
The last row matters. A trace records a browser that Playwright launched. If the bug only happens in the reporter's everyday profile, the trace of a clean profile may show a working page, which is itself a useful result: the cause is in that profile's state or extensions. Works in incognito covers that split.
Check what the trace holds before sending it#
In our fixture we set a cookie named sid, sent a request with an Authorization: Bearer header and posted a JSON body with a password field. The cookie value and the bearer token were in trace.network and trace.trace, and the posted body was in resources/. A trace is as sensitive as a HAR file, because it holds the same requests.
- Reproduce with a test account.
- Search the unzipped files for your session cookie's name,
authorization,tokenand the test account's email address. - Share it through a channel with access control, not a public issue, unless every value in it is synthetic.
Worked example: a filter that resets on the second page#
This example is fictional. A tester reports that a product list's category filter resets when they open page two. The video shows the filter chip disappearing.
The trace shows the click on Next and the request it made: GET /api/products?page=2, with no category parameter. The DOM snapshot before the click shows the chip rendered and the URL still /products?category=tools. The maintainer reads the pagination handler and finds it builds a new query string from the page number alone. The video showed the effect; the trace showed the request that caused it.
Questions#
Does a trace work for a bug in Firefox or Safari?
Playwright records traces for its Chromium, Firefox and WebKit builds. Its WebKit build is not Safari, so a Safari-only bug may not reproduce in it. Record the trace in the engine where the bug appears and say which one.
How large is a trace?
It grows with screenshots and response bodies. Trace only the steps around the failure, and turn off screenshots if the screencast is not needed.
Can a maintainer rerun the trace?
No. A trace is a recording to inspect. To rerun the steps, send the script that produced it, or generate one with codegen.
Return to reproducing what someone else saw for the other layers a replay needs.