Skip to main content

BrowserBackend

Trait BrowserBackend 

Source
pub trait BrowserBackend: Send + Sync {
Show 20 methods // Required methods fn capture_screenshot<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, BrowserError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_accessibility_tree<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<A11yNode>, BrowserError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_viewport(&self) -> Result<Viewport, BrowserError>; fn get_current_url(&self) -> Result<String, BrowserError>; fn get_page_title<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<String, BrowserError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn navigate<'life0, 'life1, 'async_trait>( &'life0 self, url: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn inject_click<'life0, 'async_trait>( &'life0 self, x: f64, y: f64, ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn inject_text<'life0, 'life1, 'async_trait>( &'life0 self, text: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn inject_keypress<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, key: &'life1 str, modifiers: &'life2 [Modifier], ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn inject_scroll<'life0, 'async_trait>( &'life0 self, delta_y: i32, ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn click_element<'life0, 'life1, 'async_trait>( &'life0 self, node_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn type_into_element<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, node_id: &'life1 str, text: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn focus_element<'life0, 'life1, 'async_trait>( &'life0 self, node_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn is_page_loaded<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool, BrowserError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn wait_until<'life0, 'life1, 'async_trait>( &'life0 self, condition: &'life1 WaitCondition, timeout_ms: u64, ) -> Pin<Box<dyn Future<Output = Result<bool, BrowserError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn element_exists_a11y<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, name_contains: &'life1 str, role: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<bool, BrowserError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; // Provided methods fn set_cookies<'life0, 'life1, 'async_trait>( &'life0 self, _cookies: &'life1 [CookieParam], ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn set_local_storage<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _origin: &'life1 str, _items: &'life2 [(String, String)], ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn set_extra_headers<'life0, 'life1, 'async_trait>( &'life0 self, _headers: &'life1 [(String, String)], ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn shutdown<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... }
}
Expand description

Abstract browser backend trait.

Implementations drive a real browser (Tauri WebView, headless Chromium, etc.) through human-equivalent perception and input only.

§Perception (what the AI can see)

  • Screenshots: rendered pixels
  • Accessibility tree: semantic structure exposed to assistive technologies

§Actions (what the AI can do)

  • Click, type, scroll, keypress — all map 1:1 to human input
  • Navigation — equivalent to typing a URL

§Disallowed

  • DOM traversal, JS execution for data extraction, hidden attributes
  • Network traffic inspection, cookie/storage introspection

Required Methods§

Source

fn capture_screenshot<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, BrowserError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Capture a screenshot of the current page as PNG data.

Source

fn get_accessibility_tree<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<A11yNode>, BrowserError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Extract the accessibility tree from the current page.

Source

fn get_viewport(&self) -> Result<Viewport, BrowserError>

Get the current viewport dimensions.

Source

fn get_current_url(&self) -> Result<String, BrowserError>

Get the current page URL.

Source

fn get_page_title<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<String, BrowserError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the current page title.

Source

fn navigate<'life0, 'life1, 'async_trait>( &'life0 self, url: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Navigate to a URL.

Source

fn inject_click<'life0, 'async_trait>( &'life0 self, x: f64, y: f64, ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Click at viewport coordinates.

Source

fn inject_text<'life0, 'life1, 'async_trait>( &'life0 self, text: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Type text into the focused element.

Source

fn inject_keypress<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, key: &'life1 str, modifiers: &'life2 [Modifier], ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Press a key with optional modifiers.

Source

fn inject_scroll<'life0, 'async_trait>( &'life0 self, delta_y: i32, ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Scroll the page.

Source

fn click_element<'life0, 'life1, 'async_trait>( &'life0 self, node_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Click an element by accessibility node ID (AXPress).

Source

fn type_into_element<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, node_id: &'life1 str, text: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Type text into an element by accessibility node ID.

Source

fn focus_element<'life0, 'life1, 'async_trait>( &'life0 self, node_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Focus an element by accessibility node ID.

Source

fn is_page_loaded<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool, BrowserError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if page is fully loaded.

Source

fn wait_until<'life0, 'life1, 'async_trait>( &'life0 self, condition: &'life1 WaitCondition, timeout_ms: u64, ) -> Pin<Box<dyn Future<Output = Result<bool, BrowserError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Wait for a condition to be met.

Source

fn element_exists_a11y<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, name_contains: &'life1 str, role: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<bool, BrowserError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Check if an element matching a description exists in the accessibility tree.

Provided Methods§

Source

fn set_cookies<'life0, 'life1, 'async_trait>( &'life0 self, _cookies: &'life1 [CookieParam], ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Inject cookies into the browser. Must be called before navigation for the cookies to be sent with the first request.

Source

fn set_local_storage<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _origin: &'life1 str, _items: &'life2 [(String, String)], ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Set localStorage items for a given origin. The browser will briefly navigate to the origin to set the items.

Source

fn set_extra_headers<'life0, 'life1, 'async_trait>( &'life0 self, _headers: &'life1 [(String, String)], ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Set extra HTTP headers to include on every request.

Source

fn shutdown<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Shut down the browser backend and release resources.

For headless Chromium: terminates the browser process. For Tauri: WebView cleanup. Default: no-op.

Implementors§