pub struct HarCapture { /* private fields */ }Expand description
Captures HTTP Archive (HAR) data for a page by listening to Chrome’s
Network domain events. Start it via crate::Page::start_har_capture.
§Example
let browser = Browser::launch_chrome(None).await?;
let page = browser.new_page().await?;
let har = page.start_har_capture().await?;
page.goto("https://example.com", WaitUntil::Load).await?;
let archive = har.export().await;
let json = serde_json::to_string_pretty(&archive)?;
std::fs::write("trace.har", json)?;Implementations§
Source§impl HarCapture
impl HarCapture
Sourcepub async fn start(&self) -> Result<()>
pub async fn start(&self) -> Result<()>
Listen to CDP Network events and accumulate HAR entries.
Call this to start capturing. Events are processed in a background
task until stop or the HarCapture is dropped.
Sourcepub async fn stop(&self) -> HarArchive
pub async fn stop(&self) -> HarArchive
Stop the capture and return the complete HAR archive.
This drains any remaining pending requests (for requests that were sent but never received a response) and returns the full HAR.
Sourcepub async fn export(&self) -> HarArchive
pub async fn export(&self) -> HarArchive
Export the current HAR without stopping the capture.
Auto Trait Implementations§
impl Freeze for HarCapture
impl !RefUnwindSafe for HarCapture
impl Send for HarCapture
impl Sync for HarCapture
impl Unpin for HarCapture
impl UnsafeUnpin for HarCapture
impl !UnwindSafe for HarCapture
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more