pub struct Session { /* private fields */ }Expand description
A browser session that owns its browser and page. This is the primary API for most use cases.
Implementations§
Source§impl Session
impl Session
Sourcepub async fn launch_with_config(stealth: StealthConfig) -> Result<Self>
pub async fn launch_with_config(stealth: StealthConfig) -> Result<Self>
Launch with custom stealth config.
Sourcepub fn set_observe_config(&mut self, config: ObserveConfig)
pub fn set_observe_config(&mut self, config: ObserveConfig)
Set observation config.
Sourcepub async fn observe(&mut self) -> Result<&[InteractiveElement]>
pub async fn observe(&mut self) -> Result<&[InteractiveElement]>
Snapshot the page: enumerate all interactive elements.
Sourcepub async fn screenshot(&mut self) -> Result<Vec<u8>>
pub async fn screenshot(&mut self) -> Result<Vec<u8>>
Take an annotated screenshot with numbered boxes on each element.
Sourcepub fn element_list(&self) -> String
pub fn element_list(&self) -> String
Compact text list for LLM consumption.
Sourcepub fn get(&self, index: usize) -> Option<&InteractiveElement>
pub fn get(&self, index: usize) -> Option<&InteractiveElement>
Get element info by index.
Sourcepub fn elements(&self) -> &[InteractiveElement]
pub fn elements(&self) -> &[InteractiveElement]
Get all observed elements.
Sourcepub fn find_by_text(&self, needle: &str) -> Option<usize>
pub fn find_by_text(&self, needle: &str) -> Option<usize>
Find first element whose text contains the given substring (case-insensitive).
Sourcepub async fn click(&mut self, index: usize) -> Result<()>
pub async fn click(&mut self, index: usize) -> Result<()>
Click an element, auto-recovering if stale. Clears element cache since clicks often trigger navigation/DOM changes.
Sourcepub async fn fill(&mut self, index: usize, text: &str) -> Result<()>
pub async fn fill(&mut self, index: usize, text: &str) -> Result<()>
Fill an element, auto-recovering if stale. Does NOT clear element cache (typing rarely changes DOM structure).
Sourcepub async fn select(&mut self, index: usize, value: &str) -> Result<()>
pub async fn select(&mut self, index: usize, value: &str) -> Result<()>
Select a dropdown option, auto-recovering if stale. Clears element cache since onChange handlers may modify DOM.
Sourcepub async fn scroll_down(&self) -> Result<()>
pub async fn scroll_down(&self) -> Result<()>
Scroll down by approximately one viewport height.
Sourcepub async fn scroll_to_top(&self) -> Result<()>
pub async fn scroll_to_top(&self) -> Result<()>
Scroll to top.
Sourcepub async fn scroll_to_bottom(&self) -> Result<()>
pub async fn scroll_to_bottom(&self) -> Result<()>
Scroll to bottom.
Sourcepub async fn wait_for_stable(&self) -> Result<()>
pub async fn wait_for_stable(&self) -> Result<()>
Wait for the page to stabilize after an action. Waits up to 2s for network idle, then 50ms for DOM settle. Intentionally succeeds even if network doesn’t fully idle (some sites never stop polling).
Sourcepub async fn eval<T: DeserializeOwned>(&self, js: &str) -> Result<T>
pub async fn eval<T: DeserializeOwned>(&self, js: &str) -> Result<T>
Evaluate JavaScript and return the result.
Sourcepub async fn spa_info(&self) -> Result<SpaRouterInfo>
pub async fn spa_info(&self) -> Result<SpaRouterInfo>
Detect the SPA router type and current route state.
Navigate the SPA to a new path without page reload. Automatically detects the router type and uses the appropriate navigation method. Clears element cache since the DOM will change.
Sourcepub async fn history_go(&mut self, delta: i32) -> Result<()>
pub async fn history_go(&mut self, delta: i32) -> Result<()>
Navigate browser history by delta steps. delta = -1 goes back, delta = 1 goes forward. Clears element cache since the DOM will change.