Skip to main content

Page

Struct Page 

Source
pub struct Page { /* private fields */ }
Expand description

A browser page with stealth capabilities

Implementations§

Source§

impl Page

Source

pub fn session(&self) -> &Session

Get the underlying CDP session

Source

pub fn target_id(&self) -> &str

Get the target ID for this page (tab identifier)

Source

pub async fn goto(&self, url: &str) -> Result<()>

Navigate to a URL

Source

pub async fn reload(&self) -> Result<()>

Reload the page

Source

pub async fn back(&self) -> Result<()>

Go back in history

Source

pub async fn forward(&self) -> Result<()>

Go forward in history

Source

pub async fn url(&self) -> Result<String>

Get current URL

Source

pub async fn title(&self) -> Result<String>

Get page title

Source

pub async fn content(&self) -> Result<String>

Get page HTML content

Source

pub async fn text(&self) -> Result<String>

Get page text content (body innerText)

Source

pub async fn screenshot(&self) -> Result<Vec<u8>>

Capture a screenshot as PNG bytes

Source

pub async fn screenshot_jpeg(&self, quality: u8) -> Result<Vec<u8>>

Capture a screenshot as JPEG with quality

Source

pub async fn find(&self, selector: &str) -> Result<Element<'_>>

Find an element by CSS selector

Source

pub async fn find_all(&self, selector: &str) -> Result<Vec<Element<'_>>>

Find all elements matching a CSS selector

Source

pub async fn exists(&self, selector: &str) -> bool

Check if an element exists

Source

pub async fn find_by_text(&self, text: &str) -> Result<Element<'_>>

Find an element by its text content (case-insensitive contains)

Source

pub async fn find_by_text_match( &self, text: &str, match_type: TextMatch, ) -> Result<Element<'_>>

Find an element by text with specific matching strategy

Prioritizes interactive elements (a, button, input) over static elements. Uses Runtime.callFunctionOn to avoid mutating the DOM (no marker attributes).

Source

pub async fn find_all_by_text(&self, text: &str) -> Result<Vec<Element<'_>>>

Find all elements matching the given text

Source

pub async fn text_exists(&self, text: &str) -> bool

Check if an element with the given text exists

Source

pub async fn click_at(&self, x: f64, y: f64) -> Result<()>

Click at coordinates

Source

pub async fn click(&self, selector: &str) -> Result<()>

Click on an element by selector

Source

pub async fn type_text(&self, text: &str) -> Result<()>

Type text into focused element

Source

pub async fn type_into(&self, selector: &str, text: &str) -> Result<()>

Type text into an element by selector

Source

pub async fn click_by_text(&self, text: &str) -> Result<()>

Click an element by its text content

Source

pub async fn try_click(&self, selector: &str) -> Result<bool>

Try to click an element, returning Ok(false) if not found or not clickable

Source

pub async fn try_click_by_text(&self, text: &str) -> Result<bool>

Try to click an element by text, returning Ok(false) if not found or not clickable

Source

pub async fn fill(&self, selector: &str, value: &str) -> Result<()>

Fill a form field: click, clear, type

Source

pub fn human(&self) -> Human<'_>

Get a Human helper for human-like interactions

Source

pub async fn human_click(&self, selector: &str) -> Result<()>

Human-like click on an element

Source

pub async fn human_type(&self, selector: &str, text: &str) -> Result<()>

Human-like typing into an element

Source

pub async fn human_click_by_text(&self, text: &str) -> Result<()>

Human-like click on an element found by text content

Source

pub async fn try_human_click(&self, selector: &str) -> Result<bool>

Try to human-click an element, returning Ok(true) if clicked, Ok(false) if not found or not clickable

Source

pub async fn try_human_click_by_text(&self, text: &str) -> Result<bool>

Try to human-click an element by text, returning Ok(true) if clicked, Ok(false) if not found or not clickable

Source

pub async fn human_fill(&self, selector: &str, value: &str) -> Result<()>

Human-like form fill: click, clear, type with natural delays

Source

pub async fn evaluate<T: DeserializeOwned>(&self, expression: &str) -> Result<T>

Evaluate JavaScript and return the result

Source

pub async fn evaluate_sync<T: DeserializeOwned>( &self, expression: &str, ) -> Result<T>

Evaluate JavaScript synchronously (don’t await promises). Use when the page may have unresolved promises that block normal evaluate.

Source

pub async fn execute(&self, expression: &str) -> Result<()>

Execute JavaScript without expecting a return value

Source

pub async fn execute_sync(&self, expression: &str) -> Result<()>

Execute JavaScript synchronously (don’t await promises)

Source

pub async fn cookies(&self) -> Result<Vec<Cookie>>

Get all cookies

Set a cookie

Delete a cookie

Source

pub async fn clear_all_cookies(&self) -> Result<()>

Clear all browser cookies for this context.

Source

pub async fn set_cookies_bulk( &self, cookies: Vec<NetworkSetCookie>, ) -> Result<()>

Bulk-import cookies (e.g., restored from a prior dump_storage call).

Source

pub async fn set_extra_headers( &self, headers: HashMap<String, String>, ) -> Result<()>

Set extra HTTP headers sent with every subsequent request from this page. Pass an empty map to clear.

Source

pub async fn clear_extra_headers(&self) -> Result<()>

Remove all extra HTTP headers set via set_extra_headers.

Source

pub async fn goto_with_headers( &self, url: &str, headers: HashMap<String, String>, ) -> Result<()>

Navigate to url while sending custom HTTP headers. Headers are set before navigation and cleared afterward.

Source

pub async fn goto_with_referrer(&self, url: &str, referrer: &str) -> Result<()>

Navigate to url with a custom Referer header.

Source

pub async fn set_bypass_csp(&self, enabled: bool) -> Result<()>

Disable CSP enforcement for the current page. Must be called before navigation to take effect.

Source

pub async fn set_user_agent(&self, user_agent: &str) -> Result<()>

Override the User-Agent string for this page.

Source

pub async fn ignore_cert_errors(&self, ignore: bool) -> Result<()>

Ignore TLS certificate errors for this session.

Source

pub async fn accept_dialog(&self, prompt_text: Option<&str>) -> Result<()>

Accept a pending JS dialog (alert / confirm / prompt). For prompt() dialogs, provide prompt_text to fill the input.

Source

pub async fn dismiss_dialog(&self) -> Result<()>

Dismiss a pending JS dialog (cancel / close).

Source

pub async fn wait_for( &self, selector: &str, timeout_ms: u64, ) -> Result<Element<'_>>

Wait for an element to appear in the DOM

Source

pub async fn wait_for_visible( &self, selector: &str, timeout_ms: u64, ) -> Result<Element<'_>>

Wait for an element to be visible and clickable

Source

pub async fn wait_for_hidden( &self, selector: &str, timeout_ms: u64, ) -> Result<()>

Wait for an element to disappear

Source

pub async fn wait(&self, ms: u64)

Wait for a fixed duration

Source

pub async fn wait_for_text( &self, text: &str, timeout_ms: u64, ) -> Result<Element<'_>>

Wait for an element with specific text to appear

Source

pub async fn wait_for_url_contains( &self, pattern: &str, timeout_ms: u64, ) -> Result<()>

Wait for the URL to contain a specific string

Source

pub async fn wait_for_url_change(&self, timeout_ms: u64) -> Result<String>

Wait for URL to change from current URL

Source

pub async fn enable_request_capture(&self) -> Result<()>

Enable network request capture NOTE: This enables Network.enable which may be slightly detectable by advanced anti-bot

Source

pub async fn disable_request_capture(&self) -> Result<()>

Disable network request capture

Source

pub async fn get_response_body(&self, request_id: &str) -> Result<ResponseBody>

Get response body for a captured request The request_id comes from CapturedRequest.request_id

Source

pub async fn find_any(&self, selectors: &[&str]) -> Result<Element<'_>>

Find the first element matching any of the given selectors

Source

pub async fn wait_for_any( &self, selectors: &[&str], timeout_ms: u64, ) -> Result<Element<'_>>

Wait for any of the given selectors to appear

Returns the first selector that matches.

Source

pub async fn wait_for_network_idle( &self, idle_time_ms: u64, timeout_ms: u64, ) -> Result<()>

Wait for network to become idle (no pending XHR/fetch for idle_time_ms)

Source

pub async fn frames(&self) -> Result<Vec<FrameInfo>>

Get a list of all frames on the page

Source

pub async fn evaluate_in_frame<T: DeserializeOwned>( &self, frame_selector: &str, expression: &str, ) -> Result<T>

Execute JavaScript inside an iframe.

§Safety

expression is evaluated as code (via the Function constructor), not as a string literal. Do not pass untrusted user input as the expression — it will be executed in the iframe’s JS context.

Source

pub async fn with_retry<F, Fut, T>( &self, attempts: u32, delay_ms: u64, operation: F, ) -> Result<T>
where F: Fn() -> Fut, Fut: Future<Output = Result<T>>,

Retry an operation multiple times with delays between attempts

Source

pub async fn debug_screenshot(&self, prefix: &str) -> Result<String>

Take a debug screenshot and save it with a timestamp

Saves to StealthConfig::debug_dir if set, otherwise current directory. Useful during development to understand page state.

Source

pub async fn debug_state(&self) -> Result<PageState>

Log the current page state for debugging

Source

pub async fn upload_file(&self, selector: &str, path: &str) -> Result<()>

Upload file(s) to a file input element

Source

pub async fn upload_files(&self, selector: &str, paths: &[&str]) -> Result<()>

Upload multiple files to a file input element

Source

pub async fn select(&self, selector: &str, value: &str) -> Result<()>

Select option by value

Source

pub async fn select_by_text(&self, selector: &str, text: &str) -> Result<()>

Select option by visible text

Source

pub async fn select_multiple( &self, selector: &str, values: &[&str], ) -> Result<()>

Select multiple options by values

Source

pub async fn hover(&self, selector: &str) -> Result<()>

Hover over element (for revealing menus)

Source

pub async fn human_hover(&self, selector: &str) -> Result<()>

Human-like hover with Bezier curve movement

Source

pub async fn press_key(&self, key: &str) -> Result<()>

Press key with optional modifiers (e.g., “Enter”, “Ctrl+A”, “Cmd+Shift+S”)

Source

pub async fn select_all(&self) -> Result<()>

Platform-aware select all (Cmd+A on Mac, Ctrl+A elsewhere)

Source

pub async fn copy(&self) -> Result<()>

Platform-aware copy (Cmd+C on Mac, Ctrl+C elsewhere)

Source

pub async fn paste(&self) -> Result<()>

Platform-aware paste (Cmd+V on Mac, Ctrl+V elsewhere)

Auto Trait Implementations§

§

impl Freeze for Page

§

impl !RefUnwindSafe for Page

§

impl Send for Page

§

impl Sync for Page

§

impl Unpin for Page

§

impl UnsafeUnpin for Page

§

impl !UnwindSafe for Page

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more