public interface Tracing
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")));
Modifier and Type | Interface and Description |
---|---|
static class |
Tracing.StartChunkOptions |
static class |
Tracing.StartOptions |
static class |
Tracing.StopChunkOptions |
static class |
Tracing.StopOptions |
Modifier and Type | Method and Description |
---|---|
default void |
start()
Start tracing.
|
void |
start(Tracing.StartOptions options)
Start tracing.
|
default void |
startChunk()
Start a new trace chunk.
|
void |
startChunk(Tracing.StartChunkOptions options)
Start a new trace chunk.
|
default void |
stop()
Stop tracing.
|
void |
stop(Tracing.StopOptions options)
Stop tracing.
|
default void |
stopChunk()
Stop the trace chunk.
|
void |
stopChunk(Tracing.StopChunkOptions options)
Stop the trace chunk.
|
default void start()
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")));
void start(Tracing.StartOptions options)
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")));
default void startChunk()
BrowserContext
, use Tracing.start()
once, and then create multiple trace chunks with Tracing.startChunk()
and
Tracing.stopChunk()
.
context.tracing().start(new Tracing.StartOptions()
.setScreenshots(true)
.setSnapshots(true));
Page page = context.newPage();
page.navigate("https://playwright.dev");
context.tracing().startChunk();
page.click("text=Get Started");
// Everything between startChunk and stopChunk will be recorded in the trace.
context.tracing().stopChunk(new Tracing.StopChunkOptions()
.setPath(Paths.get("trace1.zip")));
context.tracing().startChunk();
page.navigate("http://example.com");
// Save a second trace file with different actions.
context.tracing().stopChunk(new Tracing.StopChunkOptions()
.setPath(Paths.get("trace2.zip")));
void startChunk(Tracing.StartChunkOptions options)
BrowserContext
, use Tracing.start()
once, and then create multiple trace chunks with Tracing.startChunk()
and
Tracing.stopChunk()
.
context.tracing().start(new Tracing.StartOptions()
.setScreenshots(true)
.setSnapshots(true));
Page page = context.newPage();
page.navigate("https://playwright.dev");
context.tracing().startChunk();
page.click("text=Get Started");
// Everything between startChunk and stopChunk will be recorded in the trace.
context.tracing().stopChunk(new Tracing.StopChunkOptions()
.setPath(Paths.get("trace1.zip")));
context.tracing().startChunk();
page.navigate("http://example.com");
// Save a second trace file with different actions.
context.tracing().stopChunk(new Tracing.StopChunkOptions()
.setPath(Paths.get("trace2.zip")));
default void stop()
void stop(Tracing.StopOptions options)
default void stopChunk()
Tracing.startChunk()
for more details about multiple trace chunks.void stopChunk(Tracing.StopChunkOptions options)
Tracing.startChunk()
for more details about multiple trace chunks.Copyright © 2022. All rights reserved.