pub struct Page { /* private fields */ }Expand description
A browser page with stealth capabilities
Implementations§
Source§impl Page
impl Page
Sourcepub async fn screenshot(&self) -> Result<Vec<u8>>
pub async fn screenshot(&self) -> Result<Vec<u8>>
Capture a screenshot as PNG bytes
Sourcepub async fn screenshot_jpeg(&self, quality: u8) -> Result<Vec<u8>>
pub async fn screenshot_jpeg(&self, quality: u8) -> Result<Vec<u8>>
Capture a screenshot as JPEG with quality
Sourcepub async fn find(&self, selector: &str) -> Result<Element<'_>>
pub async fn find(&self, selector: &str) -> Result<Element<'_>>
Find an element by CSS selector
Sourcepub async fn find_all(&self, selector: &str) -> Result<Vec<Element<'_>>>
pub async fn find_all(&self, selector: &str) -> Result<Vec<Element<'_>>>
Find all elements matching a CSS selector
Sourcepub async fn find_by_text(&self, text: &str) -> Result<Element<'_>>
pub async fn find_by_text(&self, text: &str) -> Result<Element<'_>>
Find an element by its text content (case-insensitive contains)
Sourcepub async fn find_by_text_match(
&self,
text: &str,
match_type: TextMatch,
) -> Result<Element<'_>>
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).
Sourcepub async fn find_all_by_text(&self, text: &str) -> Result<Vec<Element<'_>>>
pub async fn find_all_by_text(&self, text: &str) -> Result<Vec<Element<'_>>>
Find all elements matching the given text
Sourcepub async fn text_exists(&self, text: &str) -> bool
pub async fn text_exists(&self, text: &str) -> bool
Check if an element with the given text exists
Sourcepub async fn type_into(&self, selector: &str, text: &str) -> Result<()>
pub async fn type_into(&self, selector: &str, text: &str) -> Result<()>
Type text into an element by selector
Sourcepub async fn click_by_text(&self, text: &str) -> Result<()>
pub async fn click_by_text(&self, text: &str) -> Result<()>
Click an element by its text content
Sourcepub async fn try_click(&self, selector: &str) -> Result<bool>
pub async fn try_click(&self, selector: &str) -> Result<bool>
Try to click an element, returning Ok(false) if not found or not clickable
Sourcepub async fn try_click_by_text(&self, text: &str) -> Result<bool>
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
Sourcepub async fn fill(&self, selector: &str, value: &str) -> Result<()>
pub async fn fill(&self, selector: &str, value: &str) -> Result<()>
Fill a form field: click, clear, type
Sourcepub async fn human_click(&self, selector: &str) -> Result<()>
pub async fn human_click(&self, selector: &str) -> Result<()>
Human-like click on an element
Sourcepub async fn human_type(&self, selector: &str, text: &str) -> Result<()>
pub async fn human_type(&self, selector: &str, text: &str) -> Result<()>
Human-like typing into an element
Sourcepub async fn human_click_by_text(&self, text: &str) -> Result<()>
pub async fn human_click_by_text(&self, text: &str) -> Result<()>
Human-like click on an element found by text content
Sourcepub async fn try_human_click(&self, selector: &str) -> Result<bool>
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
Sourcepub async fn try_human_click_by_text(&self, text: &str) -> Result<bool>
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
Sourcepub async fn human_fill(&self, selector: &str, value: &str) -> Result<()>
pub async fn human_fill(&self, selector: &str, value: &str) -> Result<()>
Human-like form fill: click, clear, type with natural delays
Sourcepub async fn evaluate<T: DeserializeOwned>(&self, expression: &str) -> Result<T>
pub async fn evaluate<T: DeserializeOwned>(&self, expression: &str) -> Result<T>
Evaluate JavaScript and return the result
Sourcepub async fn evaluate_sync<T: DeserializeOwned>(
&self,
expression: &str,
) -> Result<T>
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.
Sourcepub async fn execute(&self, expression: &str) -> Result<()>
pub async fn execute(&self, expression: &str) -> Result<()>
Execute JavaScript without expecting a return value
Sourcepub async fn execute_sync(&self, expression: &str) -> Result<()>
pub async fn execute_sync(&self, expression: &str) -> Result<()>
Execute JavaScript synchronously (don’t await promises)
Get all cookies
Set a cookie
Delete a cookie
Clear all browser cookies for this context.
Bulk-import cookies (e.g., restored from a prior dump_storage call).
Sourcepub async fn set_extra_headers(
&self,
headers: HashMap<String, String>,
) -> Result<()>
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.
Sourcepub async fn clear_extra_headers(&self) -> Result<()>
pub async fn clear_extra_headers(&self) -> Result<()>
Remove all extra HTTP headers set via set_extra_headers.
Sourcepub async fn goto_with_headers(
&self,
url: &str,
headers: HashMap<String, String>,
) -> Result<()>
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.
Sourcepub async fn goto_with_referrer(&self, url: &str, referrer: &str) -> Result<()>
pub async fn goto_with_referrer(&self, url: &str, referrer: &str) -> Result<()>
Navigate to url with a custom Referer header.
Sourcepub async fn set_bypass_csp(&self, enabled: bool) -> Result<()>
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.
Sourcepub async fn set_user_agent(&self, user_agent: &str) -> Result<()>
pub async fn set_user_agent(&self, user_agent: &str) -> Result<()>
Override the User-Agent string for this page.
Sourcepub async fn ignore_cert_errors(&self, ignore: bool) -> Result<()>
pub async fn ignore_cert_errors(&self, ignore: bool) -> Result<()>
Ignore TLS certificate errors for this session.
Sourcepub async fn accept_dialog(&self, prompt_text: Option<&str>) -> Result<()>
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.
Sourcepub async fn dismiss_dialog(&self) -> Result<()>
pub async fn dismiss_dialog(&self) -> Result<()>
Dismiss a pending JS dialog (cancel / close).
Sourcepub async fn wait_for(
&self,
selector: &str,
timeout_ms: u64,
) -> Result<Element<'_>>
pub async fn wait_for( &self, selector: &str, timeout_ms: u64, ) -> Result<Element<'_>>
Wait for an element to appear in the DOM
Sourcepub async fn wait_for_visible(
&self,
selector: &str,
timeout_ms: u64,
) -> Result<Element<'_>>
pub async fn wait_for_visible( &self, selector: &str, timeout_ms: u64, ) -> Result<Element<'_>>
Wait for an element to be visible and clickable
Wait for an element to disappear
Sourcepub async fn wait_for_text(
&self,
text: &str,
timeout_ms: u64,
) -> Result<Element<'_>>
pub async fn wait_for_text( &self, text: &str, timeout_ms: u64, ) -> Result<Element<'_>>
Wait for an element with specific text to appear
Sourcepub async fn wait_for_url_contains(
&self,
pattern: &str,
timeout_ms: u64,
) -> Result<()>
pub async fn wait_for_url_contains( &self, pattern: &str, timeout_ms: u64, ) -> Result<()>
Wait for the URL to contain a specific string
Sourcepub async fn wait_for_url_change(&self, timeout_ms: u64) -> Result<String>
pub async fn wait_for_url_change(&self, timeout_ms: u64) -> Result<String>
Wait for URL to change from current URL
Sourcepub async fn enable_request_capture(&self) -> Result<()>
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
Sourcepub async fn disable_request_capture(&self) -> Result<()>
pub async fn disable_request_capture(&self) -> Result<()>
Disable network request capture
Sourcepub async fn get_response_body(&self, request_id: &str) -> Result<ResponseBody>
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
Sourcepub async fn find_any(&self, selectors: &[&str]) -> Result<Element<'_>>
pub async fn find_any(&self, selectors: &[&str]) -> Result<Element<'_>>
Find the first element matching any of the given selectors
Sourcepub async fn wait_for_any(
&self,
selectors: &[&str],
timeout_ms: u64,
) -> Result<Element<'_>>
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.
Sourcepub async fn wait_for_network_idle(
&self,
idle_time_ms: u64,
timeout_ms: u64,
) -> Result<()>
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)
Sourcepub async fn evaluate_in_frame<T: DeserializeOwned>(
&self,
frame_selector: &str,
expression: &str,
) -> Result<T>
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.
Sourcepub async fn with_retry<F, Fut, T>(
&self,
attempts: u32,
delay_ms: u64,
operation: F,
) -> Result<T>
pub async fn with_retry<F, Fut, T>( &self, attempts: u32, delay_ms: u64, operation: F, ) -> Result<T>
Retry an operation multiple times with delays between attempts
Sourcepub async fn debug_screenshot(&self, prefix: &str) -> Result<String>
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.
Sourcepub async fn debug_state(&self) -> Result<PageState>
pub async fn debug_state(&self) -> Result<PageState>
Log the current page state for debugging
Sourcepub async fn upload_file(&self, selector: &str, path: &str) -> Result<()>
pub async fn upload_file(&self, selector: &str, path: &str) -> Result<()>
Upload file(s) to a file input element
Sourcepub async fn upload_files(&self, selector: &str, paths: &[&str]) -> Result<()>
pub async fn upload_files(&self, selector: &str, paths: &[&str]) -> Result<()>
Upload multiple files to a file input element
Sourcepub async fn select_by_text(&self, selector: &str, text: &str) -> Result<()>
pub async fn select_by_text(&self, selector: &str, text: &str) -> Result<()>
Select option by visible text
Sourcepub async fn select_multiple(
&self,
selector: &str,
values: &[&str],
) -> Result<()>
pub async fn select_multiple( &self, selector: &str, values: &[&str], ) -> Result<()>
Select multiple options by values
Sourcepub async fn hover(&self, selector: &str) -> Result<()>
pub async fn hover(&self, selector: &str) -> Result<()>
Hover over element (for revealing menus)
Sourcepub async fn human_hover(&self, selector: &str) -> Result<()>
pub async fn human_hover(&self, selector: &str) -> Result<()>
Human-like hover with Bezier curve movement
Sourcepub async fn press_key(&self, key: &str) -> Result<()>
pub async fn press_key(&self, key: &str) -> Result<()>
Press key with optional modifiers (e.g., “Enter”, “Ctrl+A”, “Cmd+Shift+S”)
Sourcepub async fn select_all(&self) -> Result<()>
pub async fn select_all(&self) -> Result<()>
Platform-aware select all (Cmd+A on Mac, Ctrl+A elsewhere)