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
Get a cookie manager for the current browser context
Sourcepub fn console_manager(&self) -> Result<ConsoleManager>
pub fn console_manager(&self) -> Result<ConsoleManager>
Get a console log manager for the current browser context
Sourcepub fn storage_manager(&self) -> StorageManager
pub fn storage_manager(&self) -> StorageManager
Get a storage manager for the current browser context
Sourcepub fn viewport_manager(&self) -> Result<ViewportManager>
pub fn viewport_manager(&self) -> Result<ViewportManager>
Get a viewport manager for the current browser context
Sourcepub fn pdf_manager(&self) -> Result<PdfManager>
pub fn pdf_manager(&self) -> Result<PdfManager>
Get a PDF manager for the current browser context
Sourcepub fn download_manager(&self) -> Result<DownloadManager>
pub fn download_manager(&self) -> Result<DownloadManager>
Get a download manager for the current browser context
Sourcepub fn auth_manager(&self) -> Result<AuthManager>
pub fn auth_manager(&self) -> Result<AuthManager>
Get an auth manager for the current browser context
Sourcepub fn performance_manager(&self) -> Result<PerformanceManager>
pub fn performance_manager(&self) -> Result<PerformanceManager>
Get a performance manager for the current browser context
Sourcepub fn har_manager(&self) -> Result<HarManager>
pub fn har_manager(&self) -> Result<HarManager>
Get a HAR manager for the current browser context
Sourcepub fn coverage_manager(&self) -> Result<CoverageManager>
pub fn coverage_manager(&self) -> Result<CoverageManager>
Get a coverage manager for the current browser context
Sourcepub fn network_interceptor(&self) -> Result<NetworkInterceptor>
pub fn network_interceptor(&self) -> Result<NetworkInterceptor>
Get a network interceptor for the current browser context
Sourcepub fn dialog_manager(&self) -> Result<DialogManager>
pub fn dialog_manager(&self) -> Result<DialogManager>
Get a dialog manager for the current browser context
Sourcepub fn filechooser_manager(&self) -> Result<FileChooserManager>
pub fn filechooser_manager(&self) -> Result<FileChooserManager>
Get a file chooser manager for the current browser context
Sourcepub fn permissions_manager(&self) -> Result<PermissionsManager>
pub fn permissions_manager(&self) -> Result<PermissionsManager>
Get a permissions manager for the current browser context
Sourcepub fn tracing_manager(&self) -> Result<TracingManager>
pub fn tracing_manager(&self) -> Result<TracingManager>
Get a tracing manager for the current browser context
Sourcepub async fn raw_cdp_command(
&self,
method: &str,
params: Value,
) -> Result<Value>
pub async fn raw_cdp_command( &self, method: &str, params: Value, ) -> Result<Value>
Send a raw CDP command directly (power-user access to unwrapped CDP features). Returns the raw JSON response from the browser.
Sourcepub fn touch_manager(&self) -> Result<TouchManager>
pub fn touch_manager(&self) -> Result<TouchManager>
Get a touch manager for the current browser context
Sourcepub fn worker_manager(&self) -> Result<WorkerManager>
pub fn worker_manager(&self) -> Result<WorkerManager>
Get a worker manager for the current browser context
Sourcepub fn service_worker_manager(&self) -> Result<ServiceWorkerManager>
pub fn service_worker_manager(&self) -> Result<ServiceWorkerManager>
Get a service worker manager for the current browser context
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_session_info(&self) -> Result<SessionInfo>
pub async fn get_session_info(&self) -> Result<SessionInfo>
Get session information (URL, title, target ID, session ID)
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
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_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,
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,
Use get_session_info() instead
Source§fn get_session_id(&self) -> Result<String>
fn get_session_id(&self) -> Result<String>
Use get_session_info() instead
Source§fn get_current_target_id(&self) -> Result<String>
fn get_current_target_id(&self) -> Result<String>
Use get_session_info() instead