Skip to main content

BidiBrowser

Trait BidiBrowser 

Source
pub trait BidiBrowser: Send + Sync {
    type Transport: ConnectionTransport + Send + Sync + 'static;
    type BrowserNode: Node + Send;

Show 41 methods // Required methods fn driver(&self) -> &BidiDriver<Self::Transport>; fn driver_mut(&mut self) -> &mut BidiDriver<Self::Transport>; fn build_node( &self, raw_node: NodeRemoteValue, locator: Locator, context: BrowsingContext, ) -> Self::BrowserNode; fn close(self) -> impl Future<Output = Result<(), BrowserCloseError>> + Send; // Provided methods fn navigate( &mut self, url: &str, ) -> impl Future<Output = Result<NavigateResult, NavigateError>> + Send { ... } fn navigate_with_options( &mut self, url: &str, options: NavigateOptions, ) -> impl Future<Output = Result<NavigateResult, NavigateError>> + Send { ... } fn close_context( &mut self, context: DomainBrowsingContext, ) -> impl Future<Output = Result<(), ContextCloseError>> + Send { ... } fn create_context( &mut self, background: bool, ) -> impl Future<Output = Result<DomainBrowsingContext, ContextCreationError>> + Send { ... } fn create_context_with_options( &mut self, background: bool, options: CreateContextOptions, ) -> impl Future<Output = Result<DomainBrowsingContext, ContextCreationError>> + Send { ... } fn find_nodes( &mut self, locator: Locator, ) -> impl Future<Output = Result<Vec<Self::BrowserNode>, FindNodesError>> + Send { ... } fn find_nodes_with_options( &mut self, locator: Locator, options: FindNodesOptions, ) -> impl Future<Output = Result<Vec<Self::BrowserNode>, FindNodesError>> + Send { ... } fn find_node( &mut self, locator: Locator, ) -> impl Future<Output = Result<Option<Self::BrowserNode>, FindNodesError>> + Send { ... } fn find_node_with_options( &mut self, locator: Locator, options: FindNodesOptions, ) -> impl Future<Output = Result<Option<Self::BrowserNode>, FindNodesError>> + Send { ... } fn wait_for_nodes( &mut self, locator: Locator, ) -> impl Future<Output = Result<Vec<Self::BrowserNode>, FindNodesError>> + Send { ... } fn wait_for_nodes_with_options( &mut self, locator: Locator, options: WaitForNodesOptions, ) -> impl Future<Output = Result<Vec<Self::BrowserNode>, FindNodesError>> + Send { ... } fn wait_for_node( &mut self, locator: Locator, ) -> impl Future<Output = Result<Option<Self::BrowserNode>, FindNodesError>> + Send { ... } fn wait_for_node_with_options( &mut self, locator: Locator, options: WaitForNodesOptions, ) -> impl Future<Output = Result<Option<Self::BrowserNode>, FindNodesError>> + Send { ... } fn on_request<F, Fut>( &mut self, handler: F, ) -> impl Future<Output = Result<(), InterceptNetworkError>> + Send where F: Fn(NetworkRequest<Self::Transport>) -> Fut + Send + Sync + 'static, Fut: Future<Output = ()> + Send + 'static { ... } fn on_request_with_options<F, Fut>( &mut self, handler: F, options: OnRequestOptions, ) -> impl Future<Output = Result<(), InterceptNetworkError>> + Send where F: Fn(NetworkRequest<Self::Transport>) -> Fut + Send + Sync + 'static, Fut: Future<Output = ()> + Send + 'static { ... } fn subscribe_events<F, R>( &mut self, events: HashSet<&str>, handler: F, ) -> impl Future<Output = Result<Option<SubscribeResult>, CommandResultError>> + Send where F: FnMut(Event) -> R + Send + Sync + 'static, R: Future<Output = ()> + Send + 'static { ... } fn subscribe_events_with_options<F, R>( &mut self, events: HashSet<&str>, handler: F, options: SubscribeEventsOptions, ) -> impl Future<Output = Result<Option<SubscribeResult>, CommandResultError>> + Send where F: FnMut(Event) -> R + Send + Sync + 'static, R: Future<Output = ()> + Send + 'static { ... } fn add_event_handler<F, R>( &mut self, events: HashSet<&str>, handler: F, ) -> impl Future<Output = String> + Send where F: FnMut(Event) -> R + Send + Sync + 'static, R: Future<Output = ()> + Send + 'static { ... } fn evaluate_script( &mut self, expression: String, await_promise: bool, ) -> impl Future<Output = Result<EvaluateResultSuccess, EvaluateResultError>> + Send { ... } fn evaluate_script_with_options( &mut self, expression: String, await_promise: bool, options: EvaluateScriptOptions, ) -> impl Future<Output = Result<EvaluateResultSuccess, EvaluateResultError>> + Send { ... } fn add_preload_script( &mut self, function_declaration: String, ) -> impl Future<Output = Result<String, EvaluateResultError>> + Send { ... } fn add_preload_script_with_options( &mut self, function_declaration: String, options: AddPreloadScriptOptions, ) -> impl Future<Output = Result<String, EvaluateResultError>> + Send { ... } fn remove_preload_script( &mut self, script: String, ) -> impl Future<Output = Result<(), EvaluateResultError>> + Send { ... } fn screenshot( &mut self, ) -> impl Future<Output = Result<String, ScreenshotError>> + Send { ... } fn screenshot_with_options( &mut self, options: BrowserScreenshotOptions, ) -> impl Future<Output = Result<String, ScreenshotError>> + Send { ... } fn emulate_timezone( &mut self, timezone: Option<String>, ) -> impl Future<Output = Result<(), EmulationError>> + Send { ... } fn emulate_timezone_with_options( &mut self, timezone: Option<String>, options: EmulateTimezoneOptions, ) -> impl Future<Output = Result<(), EmulationError>> + Send { ... } fn authenticate( &mut self, username: impl Into<String> + Send + 'static, password: impl Into<String> + Send + 'static, ) -> impl Future<Output = Result<(), InterceptNetworkError>> + Send { ... } fn authenticate_with_options( &mut self, username: impl Into<String> + Send + 'static, password: impl Into<String> + Send + 'static, options: AuthenticateOptions, ) -> impl Future<Output = Result<(), InterceptNetworkError>> + Send { ... } fn mouse(&self) -> &BidiMouse<Self::Transport> { ... } fn human_mouse(&self) -> &HumanMouse<BidiMouse<Self::Transport>> { ... } fn keyboard(&self) -> &BidiKeyboard<Self::Transport> { ... } fn touchscreen(&self) -> &Touchscreen<Self::Transport> { ... } fn human_touchscreen(&self) -> &HumanTouchscreen<Self::Transport> { ... } fn get_active_context_id( &self, ) -> Result<BrowsingContext, ContextIndexError> { ... } fn send_command( &mut self, command: Command, ) -> impl Future<Output = Result<CommandResponse, SessionSendError>> + Send { ... } fn end_session( &mut self, ) -> impl Future<Output = Result<(), SessionSendError>> + Send { ... }
}

Required Associated Types§

Required Methods§

Source

fn driver(&self) -> &BidiDriver<Self::Transport>

Access the underlying BiDi driver (immutable).

Source

fn driver_mut(&mut self) -> &mut BidiDriver<Self::Transport>

Access the underlying BiDi driver (mutable).

Source

fn build_node( &self, raw_node: NodeRemoteValue, locator: Locator, context: BrowsingContext, ) -> Self::BrowserNode

Construct a browser-specific node from raw BiDi data.

Source

fn close(self) -> impl Future<Output = Result<(), BrowserCloseError>> + Send

Closes the browser: ends the BiDi session, closes the WebSocket connection, and performs any browser-specific cleanup (e.g. kills the browser process).

Provided Methods§

Source

fn navigate( &mut self, url: &str, ) -> impl Future<Output = Result<NavigateResult, NavigateError>> + Send

Navigates to the specified URL in the active context.

Source

fn navigate_with_options( &mut self, url: &str, options: NavigateOptions, ) -> impl Future<Output = Result<NavigateResult, NavigateError>> + Send

Navigates to the specified URL with custom options (wait state, context).

Source

fn close_context( &mut self, context: DomainBrowsingContext, ) -> impl Future<Output = Result<(), ContextCloseError>> + Send

Closes a browsing context (tab/window).

Source

fn create_context( &mut self, background: bool, ) -> impl Future<Output = Result<DomainBrowsingContext, ContextCreationError>> + Send

Creates a new browsing context (tab) with default options.

Source

fn create_context_with_options( &mut self, background: bool, options: CreateContextOptions, ) -> impl Future<Output = Result<DomainBrowsingContext, ContextCreationError>> + Send

Creates a new browsing context with custom options (type, reference context, background).

Source

fn find_nodes( &mut self, locator: Locator, ) -> impl Future<Output = Result<Vec<Self::BrowserNode>, FindNodesError>> + Send

Finds all elements matching the given locator in the active context.

Source

fn find_nodes_with_options( &mut self, locator: Locator, options: FindNodesOptions, ) -> impl Future<Output = Result<Vec<Self::BrowserNode>, FindNodesError>> + Send

Finds all elements matching the given locator with custom options (context, count, serialization, start nodes).

Source

fn find_node( &mut self, locator: Locator, ) -> impl Future<Output = Result<Option<Self::BrowserNode>, FindNodesError>> + Send

Finds the first element matching the given locator in the active context.

Returns None if no matching element is found.

Source

fn find_node_with_options( &mut self, locator: Locator, options: FindNodesOptions, ) -> impl Future<Output = Result<Option<Self::BrowserNode>, FindNodesError>> + Send

Finds the first element matching the given locator with custom options.

Returns None if no matching element is found.

Source

fn wait_for_nodes( &mut self, locator: Locator, ) -> impl Future<Output = Result<Vec<Self::BrowserNode>, FindNodesError>> + Send

Waits for elements matching the locator to appear (default 4s timeout).

Source

fn wait_for_nodes_with_options( &mut self, locator: Locator, options: WaitForNodesOptions, ) -> impl Future<Output = Result<Vec<Self::BrowserNode>, FindNodesError>> + Send

Waits for elements matching the locator with custom options (context, timeout, poll interval).

Source

fn wait_for_node( &mut self, locator: Locator, ) -> impl Future<Output = Result<Option<Self::BrowserNode>, FindNodesError>> + Send

Waits for a single element matching the locator to appear (default 4s timeout).

Returns None if no matching element appears within the timeout.

Source

fn wait_for_node_with_options( &mut self, locator: Locator, options: WaitForNodesOptions, ) -> impl Future<Output = Result<Option<Self::BrowserNode>, FindNodesError>> + Send

Waits for a single element matching the locator with custom options.

Returns None if no matching element appears within the timeout.

Source

fn on_request<F, Fut>( &mut self, handler: F, ) -> impl Future<Output = Result<(), InterceptNetworkError>> + Send
where F: Fn(NetworkRequest<Self::Transport>) -> Fut + Send + Sync + 'static, Fut: Future<Output = ()> + Send + 'static,

Registers a handler called for each network request (all URLs, all contexts).

Source

fn on_request_with_options<F, Fut>( &mut self, handler: F, options: OnRequestOptions, ) -> impl Future<Output = Result<(), InterceptNetworkError>> + Send
where F: Fn(NetworkRequest<Self::Transport>) -> Fut + Send + Sync + 'static, Fut: Future<Output = ()> + Send + 'static,

Registers a handler called for each network request with custom URL pattern and context filters.

Source

fn subscribe_events<F, R>( &mut self, events: HashSet<&str>, handler: F, ) -> impl Future<Output = Result<Option<SubscribeResult>, CommandResultError>> + Send
where F: FnMut(Event) -> R + Send + Sync + 'static, R: Future<Output = ()> + Send + 'static,

Subscribes to browser events and registers a handler.

Source

fn subscribe_events_with_options<F, R>( &mut self, events: HashSet<&str>, handler: F, options: SubscribeEventsOptions, ) -> impl Future<Output = Result<Option<SubscribeResult>, CommandResultError>> + Send
where F: FnMut(Event) -> R + Send + Sync + 'static, R: Future<Output = ()> + Send + 'static,

Subscribes to browser events with context and user context filters.

Source

fn add_event_handler<F, R>( &mut self, events: HashSet<&str>, handler: F, ) -> impl Future<Output = String> + Send
where F: FnMut(Event) -> R + Send + Sync + 'static, R: Future<Output = ()> + Send + 'static,

Adds an event handler without sending a subscription command.

Returns the auto-generated handler ID.

Source

fn evaluate_script( &mut self, expression: String, await_promise: bool, ) -> impl Future<Output = Result<EvaluateResultSuccess, EvaluateResultError>> + Send

Evaluates a JavaScript expression in the active browsing context.

Source

fn evaluate_script_with_options( &mut self, expression: String, await_promise: bool, options: EvaluateScriptOptions, ) -> impl Future<Output = Result<EvaluateResultSuccess, EvaluateResultError>> + Send

Evaluates a JavaScript expression with custom options (target, result ownership, serialization).

Source

fn add_preload_script( &mut self, function_declaration: String, ) -> impl Future<Output = Result<String, EvaluateResultError>> + Send

Adds a preload script that runs in every new browsing context.

Source

fn add_preload_script_with_options( &mut self, function_declaration: String, options: AddPreloadScriptOptions, ) -> impl Future<Output = Result<String, EvaluateResultError>> + Send

Adds a preload script with custom options (arguments, contexts, sandbox).

Source

fn remove_preload_script( &mut self, script: String, ) -> impl Future<Output = Result<(), EvaluateResultError>> + Send

Removes a preload script by its ID.

Source

fn screenshot( &mut self, ) -> impl Future<Output = Result<String, ScreenshotError>> + Send

Captures a screenshot of the active browsing context and returns base64-encoded image data.

Source

fn screenshot_with_options( &mut self, options: BrowserScreenshotOptions, ) -> impl Future<Output = Result<String, ScreenshotError>> + Send

Captures a screenshot with custom options (context, origin, format, clip, save path).

If save_path is a directory, saves with auto-generated filename (screenshot_TIMESTAMP.png). If save_path is a file path, saves to that exact location and returns the path. If save_path is None, returns base64-encoded image data.

Source

fn emulate_timezone( &mut self, timezone: Option<String>, ) -> impl Future<Output = Result<(), EmulationError>> + Send

Emulates a timezone for the active browsing context.

Pass None to clear the override.

Source

fn emulate_timezone_with_options( &mut self, timezone: Option<String>, options: EmulateTimezoneOptions, ) -> impl Future<Output = Result<(), EmulationError>> + Send

Emulates a timezone with custom context and user context filters.

Pass None for timezone to clear the override.

Source

fn authenticate( &mut self, username: impl Into<String> + Send + 'static, password: impl Into<String> + Send + 'static, ) -> impl Future<Output = Result<(), InterceptNetworkError>> + Send

Sets HTTP authentication credentials for all requests.

Source

fn authenticate_with_options( &mut self, username: impl Into<String> + Send + 'static, password: impl Into<String> + Send + 'static, options: AuthenticateOptions, ) -> impl Future<Output = Result<(), InterceptNetworkError>> + Send

Sets HTTP authentication credentials with URL pattern and context filters.

Source

fn mouse(&self) -> &BidiMouse<Self::Transport>

Returns a reference to the direct BiDi mouse for precise, instant movements.

§Examples
let mouse = browser.mouse();
mouse.move_to(Point { x: 100.0, y: 200.0 }, &context, Default::default()).await?;
mouse.click(None, &context, Default::default()).await?;
Source

fn human_mouse(&self) -> &HumanMouse<BidiMouse<Self::Transport>>

Returns a reference to the human mouse for realistic, human-like movements with Bezier curves and jitter.

§Examples
let human_mouse = browser.human_mouse();
// Moves with natural curve and realistic delays
human_mouse.move_to(Point { x: 300.0, y: 400.0 }, &context, Default::default()).await?;
human_mouse.click(None, &context, Default::default()).await?;
Source

fn keyboard(&self) -> &BidiKeyboard<Self::Transport>

Returns a reference to the keyboard for text input and key presses.

§Examples
let keyboard = browser.keyboard();
keyboard.type_text("Hello, World!", &context, None).await?;
keyboard.press("Enter", &context, None).await?;
Source

fn touchscreen(&self) -> &Touchscreen<Self::Transport>

Source

fn human_touchscreen(&self) -> &HumanTouchscreen<Self::Transport>

Source

fn get_active_context_id(&self) -> Result<BrowsingContext, ContextIndexError>

Source

fn send_command( &mut self, command: Command, ) -> impl Future<Output = Result<CommandResponse, SessionSendError>> + Send

Sends a raw WebDriver BiDi command.

Source

fn end_session( &mut self, ) -> impl Future<Output = Result<(), SessionSendError>> + Send

Ends the BiDi session and cleans up resources.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§