Skip to main content
Version: 1.12.0

Tracing

API for collecting and saving Playwright traces. Playwright traces can be opened using the Playwright CLI after Playwright script runs.

Start with specifying the folder traces will be stored in:

const browser = await chromium.launch();
const context = await browser.newContext();
await context.tracing.start({ screenshots: true, snapshots: true });
const page = await context.newPage();
await page.goto('https://playwright.dev');
await context.tracing.stop({ path: 'trace.zip' });

tracing.start([options])#

  • options <Object>
    • name <string> If specified, the trace is going to be saved into the file with the given name inside the tracesDir folder specified in browserType.launch([options]).
    • screenshots <boolean> Whether to capture screenshots during tracing. Screenshots are used to build a timeline preview.
    • snapshots <boolean> Whether to capture DOM snapshot on every action.
  • returns: <Promise<void>>

Start tracing.

await context.tracing.start({ screenshots: true, snapshots: true });
const page = await context.newPage();
await page.goto('https://playwright.dev');
await context.tracing.stop({ path: 'trace.zip' });

tracing.stop([options])#

Stop tracing.