Skip to main content

Trace Viewer

Playwright Trace Viewer is a GUI tool that lets you explore recorded Playwright traces of your tests meaning you can go back and forward though each action of your test and visually see what was happening during each action.

You will learn

  • How to record a trace
  • How to open the HTML report
  • How to open the trace viewer

Recording a trace

Traces can be recorded using the BrowserContext.Tracing API as follows:

await using var browser = playwright.Chromium.LaunchAsync();
await using var context = await browser.NewContextAsync();

// Start tracing before creating / navigating a page.
await context.Tracing.StartAsync(new()
Screenshots = true,
Snapshots = true,
Sources = true

var page = context.NewPageAsync();
await page.GotoAsync("");

// Stop tracing and export it into a zip archive.
await context.Tracing.StopAsync(new()
Path = ""

This will record the trace and place it into the file named

Opening the trace

You can open the saved trace using Playwright CLI or in your browser on

pwsh bin/Debug/netX/playwright.ps1 show-trace

Viewing the trace

View traces of your test by clicking through each action or hovering using the timeline and see the state of the page before and after the action. Inspect the log, source and network during each step of the test. The trace viewer creates a DOM snapshot so you can fully interact with it, open devtools etc.

Playwright Trace Viewer

To learn more check out our detailed guide on Trace Viewer.