pub struct Browser { /* private fields */ }Expand description
Browser session for managing CDP connections
Implementations§
Source§impl Browser
impl Browser
Sourcepub fn new(profile: BrowserProfile) -> Self
pub fn new(profile: BrowserProfile) -> Self
Create a new Browser session with given profile
Sourcepub fn with_cdp_url(self, cdp_url: String) -> Self
pub fn with_cdp_url(self, cdp_url: String) -> Self
Set CDP URL to connect to existing browser instead of launching new one
Sourcepub async fn start(&mut self) -> Result<()>
pub async fn start(&mut self) -> Result<()>
Start the browser session (launches browser or connects to existing)
Navigate to the specified URL
Sourcepub async fn get_current_url(&self) -> Result<String>
pub async fn get_current_url(&self) -> Result<String>
Get the current page URL
Sourcepub async fn stop(&mut self) -> Result<()>
pub async fn stop(&mut self) -> Result<()>
Stop the browser session and clean up resources
§Safety Policy
IMPORTANT: This method does NOT delete browser data directories.
We never cleanup user data for safety reasons:
- Users may specify a custom
user_data_dirpointing to their real browser profile - Deleting user data (bookmarks, history, passwords, extensions) would be catastrophic
- Temporary profiles are preserved for debugging and inspection
Users are responsible for managing their own browser data directories.
Sourcepub fn get_cdp_client(&self) -> Result<Arc<CdpClient>>
pub fn get_cdp_client(&self) -> Result<Arc<CdpClient>>
Get the CDP client for the current session
Sourcepub fn get_session_id(&self) -> Result<String>
pub fn get_session_id(&self) -> Result<String>
Get the session ID for the current target
Sourcepub fn get_current_target_id(&self) -> Result<String>
pub fn get_current_target_id(&self) -> Result<String>
Get the current target ID
Sourcepub async fn take_screenshot(
&self,
path: Option<&str>,
full_page: bool,
format: Option<&str>,
quality: Option<u32>,
) -> Result<Vec<u8>>
pub async fn take_screenshot( &self, path: Option<&str>, full_page: bool, format: Option<&str>, quality: Option<u32>, ) -> Result<Vec<u8>>
Take a screenshot of the current page
Sourcepub async fn switch_to_tab(&mut self, target_id: &str) -> Result<()>
pub async fn switch_to_tab(&mut self, target_id: &str) -> Result<()>
Switch to a different tab by target ID
Sourcepub async fn get_target_id_from_tab_id(&self, tab_id: &str) -> Result<String>
pub async fn get_target_id_from_tab_id(&self, tab_id: &str) -> Result<String>
Get target ID from short tab ID (last 4 characters)
Sourcepub async fn get_current_page_title(&self) -> Result<String>
pub async fn get_current_page_title(&self) -> Result<String>
Get the current page title
Sourcepub async fn get_browser_state_summary(
&self,
include_screenshot: bool,
dom_service: Option<&DomService>,
) -> Result<BrowserStateSummary>
pub async fn get_browser_state_summary( &self, include_screenshot: bool, dom_service: Option<&DomService>, ) -> Result<BrowserStateSummary>
Get browser state summary for LLM consumption
Trait Implementations§
Source§impl BrowserClient for Browser
impl BrowserClient for Browser
Source§fn start<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn stop<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stop<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn get_current_url<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_current_url<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn create_tab<'life0, 'life1, 'async_trait>(
&'life0 mut self,
url: Option<&'life1 str>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn create_tab<'life0, 'life1, 'async_trait>(
&'life0 mut self,
url: Option<&'life1 str>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn switch_to_tab<'life0, 'life1, 'async_trait>(
&'life0 mut self,
target_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn switch_to_tab<'life0, 'life1, 'async_trait>(
&'life0 mut self,
target_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn close_tab<'life0, 'life1, 'async_trait>(
&'life0 mut self,
target_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn close_tab<'life0, 'life1, 'async_trait>(
&'life0 mut self,
target_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn get_tabs<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<TabInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_tabs<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<TabInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn get_target_id_from_tab_id<'life0, 'life1, 'async_trait>(
&'life0 self,
tab_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_target_id_from_tab_id<'life0, 'life1, 'async_trait>(
&'life0 self,
tab_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn take_screenshot<'life0, 'life1, 'async_trait>(
&'life0 self,
path: Option<&'life1 str>,
full_page: bool,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn take_screenshot<'life0, 'life1, 'async_trait>(
&'life0 self,
path: Option<&'life1 str>,
full_page: bool,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn get_current_page_title<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_current_page_title<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn get_session_id(&self) -> Result<String>
fn get_session_id(&self) -> Result<String>
Source§fn get_current_target_id(&self) -> Result<String>
fn get_current_target_id(&self) -> Result<String>
Source§fn get_session_info<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<SessionInfo>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_session_info<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<SessionInfo>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl Freeze for Browser
impl !RefUnwindSafe for Browser
impl Send for Browser
impl Sync for Browser
impl Unpin for Browser
impl !UnwindSafe for Browser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more