pub struct Tracing { /* private fields */ }Expand description
Tracing — records Playwright traces for debugging and inspection.
Trace files can be opened in the Playwright Trace Viewer. This is a Chromium-only feature; calling tracing methods on Firefox or WebKit contexts will fail.
Implementations§
Source§impl Tracing
impl Tracing
Sourcepub fn new(
parent: ParentOrConnection,
type_name: String,
guid: Arc<str>,
initializer: Value,
) -> Result<Self>
pub fn new( parent: ParentOrConnection, type_name: String, guid: Arc<str>, initializer: Value, ) -> Result<Self>
Creates a new Tracing from protocol initialization.
Called by the object factory when the server sends a __create__ message.
Sourcepub async fn start(
&self,
options: impl Into<Option<TracingStartOptions>>,
) -> Result<()>
pub async fn start( &self, options: impl Into<Option<TracingStartOptions>>, ) -> Result<()>
Start tracing.
Playwright implements tracing as a two-step process: tracingStart to
configure the trace, then tracingStartChunk to begin recording.
§Arguments
options- Optional trace configuration (name, screenshots, snapshots)
§Errors
Returns error if:
- Tracing is already active
- Communication with browser process fails
See: https://playwright.dev/docs/api/class-tracing#tracing-start
Sourcepub async fn stop(
&self,
options: impl Into<Option<TracingStopOptions>>,
) -> Result<()>
pub async fn stop( &self, options: impl Into<Option<TracingStopOptions>>, ) -> Result<()>
Stop tracing.
Playwright implements stopping as a two-step process: tracingStopChunk
to finalize the recording, then tracingStop to tear down.
If options.path is provided, the trace is exported to that file as a
.zip archive. If no path is provided, the trace is discarded.
§Arguments
options- Optional stop options; setpathto save the trace to a file
§Errors
Returns error if:
- Tracing was not active
- Communication with browser process fails
See: https://playwright.dev/docs/api/class-tracing#tracing-stop
Sourcepub async fn start_har(
&self,
path: impl Into<String>,
options: impl Into<Option<StartHarOptions>>,
) -> Result<()>
pub async fn start_har( &self, path: impl Into<String>, options: impl Into<Option<StartHarOptions>>, ) -> Result<()>
Start recording a HAR (HTTP Archive) of network traffic to path.
The HAR is written when stop_har is called. A .zip
path bundles resource bodies as separate entries (Attach); a plain
path inlines them (Embed). The recorded HAR can be opened in browser
devtools or replayed in tests via route_from_har.
§Errors
Returns an error if communication with the browser process fails.
See: https://playwright.dev/docs/api/class-tracing#tracing-start-har
Sourcepub async fn stop_har(&self) -> Result<()>
pub async fn stop_har(&self) -> Result<()>
Stop the HAR recording started by start_har and
write it to the path given there.
§Errors
Returns an error if start_har was not called first, or if
communication with the browser process fails.
See: https://playwright.dev/docs/api/class-tracing#tracing-stop-har