pub struct BrowserSession { /* private fields */ }Expand description
A browser session that wraps thirtyfour’s WebDriver.
This is the core abstraction for browser automation in ADK.
It can be shared across multiple tools via Arc<BrowserSession>.
Implementations§
Source§impl BrowserSession
impl BrowserSession
Sourcepub fn new(config: BrowserConfig) -> Self
pub fn new(config: BrowserConfig) -> Self
Create a new browser session with the given configuration.
Note: This does not start the browser immediately.
Call start() to initialize the WebDriver connection.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a browser session with default configuration.
Sourcepub fn config(&self) -> &BrowserConfig
pub fn config(&self) -> &BrowserConfig
Get the configuration.
Navigate to a URL.
Sourcepub async fn current_url(&self) -> Result<String>
pub async fn current_url(&self) -> Result<String>
Get the current URL.
Sourcepub async fn find_element(&self, selector: &str) -> Result<WebElement>
pub async fn find_element(&self, selector: &str) -> Result<WebElement>
Find an element by CSS selector.
Sourcepub async fn find_elements(&self, selector: &str) -> Result<Vec<WebElement>>
pub async fn find_elements(&self, selector: &str) -> Result<Vec<WebElement>>
Find multiple elements by CSS selector.
Sourcepub async fn find_by_xpath(&self, xpath: &str) -> Result<WebElement>
pub async fn find_by_xpath(&self, xpath: &str) -> Result<WebElement>
Find element by XPath.
Sourcepub async fn type_text(&self, selector: &str, text: &str) -> Result<()>
pub async fn type_text(&self, selector: &str, text: &str) -> Result<()>
Type text into an element.
Sourcepub async fn get_attribute(
&self,
selector: &str,
attribute: &str,
) -> Result<Option<String>>
pub async fn get_attribute( &self, selector: &str, attribute: &str, ) -> Result<Option<String>>
Get an attribute value.
Sourcepub async fn screenshot(&self) -> Result<String>
pub async fn screenshot(&self) -> Result<String>
Take a screenshot (returns base64-encoded PNG).
Sourcepub async fn screenshot_element(&self, selector: &str) -> Result<String>
pub async fn screenshot_element(&self, selector: &str) -> Result<String>
Take a screenshot of a specific element.
Sourcepub async fn execute_script(&self, script: &str) -> Result<Value>
pub async fn execute_script(&self, script: &str) -> Result<Value>
Execute JavaScript and return result.
Sourcepub async fn execute_async_script(&self, script: &str) -> Result<Value>
pub async fn execute_async_script(&self, script: &str) -> Result<Value>
Execute async JavaScript and return result.
Sourcepub async fn wait_for_element(
&self,
selector: &str,
timeout_secs: u64,
) -> Result<WebElement>
pub async fn wait_for_element( &self, selector: &str, timeout_secs: u64, ) -> Result<WebElement>
Wait for an element to be present.
Sourcepub async fn wait_for_clickable(
&self,
selector: &str,
timeout_secs: u64,
) -> Result<WebElement>
pub async fn wait_for_clickable( &self, selector: &str, timeout_secs: u64, ) -> Result<WebElement>
Wait for an element to be clickable.
Sourcepub async fn page_source(&self) -> Result<String>
pub async fn page_source(&self) -> Result<String>
Get page source HTML.
Get all cookies.
Get a cookie by name.
Add a cookie.
Delete a cookie.
Delete all cookies.
Sourcepub async fn new_window(&self) -> Result<String>
pub async fn new_window(&self) -> Result<String>
Open a new window.
Sourcepub async fn switch_to_window(&self, handle: &str) -> Result<()>
pub async fn switch_to_window(&self, handle: &str) -> Result<()>
Switch to a window by handle.
Sourcepub async fn close_window(&self) -> Result<()>
pub async fn close_window(&self) -> Result<()>
Close the current window.
Sourcepub async fn maximize_window(&self) -> Result<()>
pub async fn maximize_window(&self) -> Result<()>
Maximize window.
Sourcepub async fn minimize_window(&self) -> Result<()>
pub async fn minimize_window(&self) -> Result<()>
Minimize window.
Sourcepub async fn set_window_rect(
&self,
x: i32,
y: i32,
width: u32,
height: u32,
) -> Result<()>
pub async fn set_window_rect( &self, x: i32, y: i32, width: u32, height: u32, ) -> Result<()>
Set window size and position.
Sourcepub async fn switch_to_frame_by_index(&self, index: u16) -> Result<()>
pub async fn switch_to_frame_by_index(&self, index: u16) -> Result<()>
Switch to frame by index.
Sourcepub async fn switch_to_frame_by_selector(&self, selector: &str) -> Result<()>
pub async fn switch_to_frame_by_selector(&self, selector: &str) -> Result<()>
Switch to frame by selector.
Sourcepub async fn switch_to_parent_frame(&self) -> Result<()>
pub async fn switch_to_parent_frame(&self) -> Result<()>
Switch to parent frame.
Sourcepub async fn switch_to_default_content(&self) -> Result<()>
pub async fn switch_to_default_content(&self) -> Result<()>
Switch to default content.
Sourcepub async fn drag_and_drop(
&self,
source_selector: &str,
target_selector: &str,
) -> Result<()>
pub async fn drag_and_drop( &self, source_selector: &str, target_selector: &str, ) -> Result<()>
Drag and drop.
Sourcepub async fn right_click(&self, selector: &str) -> Result<()>
pub async fn right_click(&self, selector: &str) -> Result<()>
Right-click (context click).
Sourcepub async fn focus_element(&self, selector: &str) -> Result<()>
pub async fn focus_element(&self, selector: &str) -> Result<()>
Focus an element.
Sourcepub async fn get_element_state(&self, selector: &str) -> Result<ElementState>
pub async fn get_element_state(&self, selector: &str) -> Result<ElementState>
Get element state.