// Start tracing before test:
context.tracing().start(new Tracing.StartOptions()
.setScreenshots(true)
.setSnapshots(true)
.setSources(true));// In teardown, stop and save only if failed:
if (testFailed) {
context.tracing().stop(new Tracing.StopOptions()
.setPath(Paths.get("target/traces/trace.zip")));
}
View trace in browser:
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="show-trace target/traces/trace.zip"