Starts recording a Chrome performance trace of the page, for Tracing.stop to return.
Keep traces short: 5 seconds or less is recommended. A trace larger than 20 MB is refused (stop() fails and returns
no trace), and a busy page can produce about 15 MB in 5 seconds (less while it sits behind pjsc's automation page).
pjsc differences:
start() when stop() was not called yet; stop() still returns that trace
later in the same render. A trace never read is dropped when the render ends.stop() returns the trace as base64 text (decode it to get the trace JSON); path is ignored, no file is written.categories is refused. screenshots: true adds screenshots.start() fails while a trace is recording or waiting for its stop().await page.tracing.start({ screenshots: true });
await page.goto("https://example.com");
const trace = await page.tracing.stop(); // base64 text of the trace JSON
page.meta.store.set("trace", trace);
Optionaloptions: { screenshots?: boolean }
screenshots: also record screenshots
Stops the trace started by Tracing.start (or takes the one the 5-second automatic stop ended) and returns it as
base64 text. Fails when no trace was started, or when the trace is larger than 20 MB. Several stop() calls at the same
time all get the same trace.
You can use
tracing.startandtracing.stopto record a Chrome performance trace, which can be opened in Chrome DevTools or timeline viewer.stopreturns it as base64 text; keep traces to 5 seconds or less (traces over 20 MB are refused).