Tracing
API for collecting and saving Playwright traces. Playwright traces can be opened in Trace Viewer after Playwright script runs.
Start recording a trace before performing actions. At the end, stop tracing and save it to a file.
Browser browser = chromium.launch();
BrowserContext context = browser.newContext();
context.tracing().start(new Tracing.StartOptions()
.setScreenshots(true)
.setSnapshots(true));
Page page = context.newPage();
page.navigate("https://playwright.dev");
context.tracing().stop(new Tracing.StopOptions()
.setPath(Paths.get("trace.zip")));