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§
Sourcefn 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 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.
Sourcefn 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_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.
Sourcefn get_viewport(&self) -> Result<Viewport, BrowserError>
fn get_viewport(&self) -> Result<Viewport, BrowserError>
Get the current viewport dimensions.
Sourcefn get_current_url(&self) -> Result<String, BrowserError>
fn get_current_url(&self) -> Result<String, BrowserError>
Get the current page URL.
Sourcefn 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 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.
Navigate to a URL.
Sourcefn 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_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.
Sourcefn 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_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.
Sourcefn 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_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.
Sourcefn 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 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.
Sourcefn 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 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).
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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,
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§
Inject cookies into the browser. Must be called before navigation for the cookies to be sent with the first request.
Sourcefn 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_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.
Sourcefn 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 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.
Sourcefn shutdown<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), BrowserError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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,
Shut down the browser backend and release resources.
For headless Chromium: terminates the browser process. For Tauri: WebView cleanup. Default: no-op.