pub struct BrowserManager {
pub client: Arc<CdpClient>,
pub download_path: Option<String>,
pub ignore_https_errors: bool,
/* private fields */
}Fields§
§client: Arc<CdpClient>§download_path: Option<String>Stored download path from launch options, re-applied to new contexts (e.g., recording)
ignore_https_errors: boolWhether to ignore HTTPS certificate errors, re-applied to new contexts (e.g., recording)
Implementations§
Source§impl BrowserManager
impl BrowserManager
Sourcepub fn chrome_pid(&self) -> Option<u32>
pub fn chrome_pid(&self) -> Option<u32>
OS pid of the launched Chrome process, if this manager owns one.
Sourcepub fn temp_user_data_dir(&self) -> Option<&Path>
pub fn temp_user_data_dir(&self) -> Option<&Path>
Temporary user-data-dir created for this one-shot launch, if any.
pub async fn launch( options: LaunchOptions, engine: Option<&str>, ) -> Result<Self, String>
pub async fn enable_domains_pub(&self, session_id: &str) -> Result<(), String>
pub async fn prepare_domains_pub(&self, session_id: &str) -> Result<(), String>
pub async fn resume_if_waiting_pub( &self, session_id: &str, ) -> Result<(), String>
pub async fn enable_browser_auto_attach_pub(&self) -> Result<(), String>
pub fn active_session_id(&self) -> Result<&str, String>
pub async fn get_url(&self) -> Result<String, String>
pub async fn get_title(&self) -> Result<String, String>
pub async fn get_content(&self) -> Result<String, String>
pub async fn evaluate( &self, script: &str, _args: Option<Value>, ) -> Result<Value, String>
pub async fn wait_for_lifecycle_external( &self, wait_until: WaitUntil, session_id: &str, ) -> Result<(), String>
pub async fn close(&mut self) -> Result<(), String>
pub fn has_pages(&self) -> bool
pub fn default_timeout_ms(&self) -> u64
Sourcepub async fn is_connection_alive(&self) -> bool
pub async fn is_connection_alive(&self) -> bool
Checks if the CDP connection is alive by sending a simple command. Returns false if the command times out or fails.
Sourcepub fn has_process_exited(&mut self) -> bool
pub fn has_process_exited(&mut self) -> bool
Non-blocking check whether the locally-launched browser process has exited (crashed or terminated). Also reaps the zombie if it has exited. Returns false for external CDP connections (no child process to monitor).
pub fn get_cdp_url(&self) -> &str
Sourcepub fn chrome_host_port(&self) -> &str
pub fn chrome_host_port(&self) -> &str
Returns the Chrome debug server address as “host:port”.
pub fn active_target_id(&self) -> Result<&str, String>
Sourcepub fn is_cdp_connection(&self) -> bool
pub fn is_cdp_connection(&self) -> bool
Returns true if this manager was connected via CDP (as opposed to local launch).
pub fn is_direct_page_connection(&self) -> bool
Sourcepub async fn ensure_page(&mut self) -> Result<(), String>
pub async fn ensure_page(&mut self) -> Result<(), String>
Ensures the browser has at least one page. If pages is empty, creates a new
about:blank page and attaches to it.
Sourcepub fn update_active_page_if_needed(&mut self)
pub fn update_active_page_if_needed(&mut self)
Checks if active_page_index is still valid and adjusts it if not
(e.g., after a tab was closed).
pub fn tab_list(&self) -> Vec<Value>
Sourcepub fn resolve_tab_ref(&self, tab_ref: &TabRef) -> Result<u32, String>
pub fn resolve_tab_ref(&self, tab_ref: &TabRef) -> Result<u32, String>
Resolve a user-supplied TabRef (either t<N> or a label) to the
stable numeric tab_id. Returns a teaching error for unknown tabs.
Sourcepub fn has_label(&self, label: &str) -> bool
pub fn has_label(&self, label: &str) -> bool
Returns true iff a tab already carries the given label.
pub async fn tab_new( &mut self, url: Option<&str>, label: Option<&str>, ) -> Result<Value, String>
Sourcepub async fn tab_new_in_context(
&mut self,
url: Option<&str>,
label: Option<&str>,
browser_context_id: Option<String>,
) -> Result<Value, String>
pub async fn tab_new_in_context( &mut self, url: Option<&str>, label: Option<&str>, browser_context_id: Option<String>, ) -> Result<Value, String>
Create a tab, optionally inside a BrowserContext (cookie/storage isolation).
Sourcepub async fn create_browser_context(&self) -> Result<String, String>
pub async fn create_browser_context(&self) -> Result<String, String>
Create an isolated BrowserContext and return its id.
pub async fn tab_switch(&mut self, index: usize) -> Result<Value, String>
pub async fn tab_close(&mut self, index: Option<usize>) -> Result<Value, String>
pub async fn set_viewport( &self, width: i32, height: i32, device_scale_factor: f64, mobile: bool, ) -> Result<(), String>
pub async fn set_user_agent(&self, user_agent: &str) -> Result<(), String>
pub async fn set_emulated_media( &self, media: Option<&str>, features: Option<Vec<(String, String)>>, ) -> Result<(), String>
pub async fn bring_to_front(&self) -> Result<(), String>
pub async fn set_timezone(&self, timezone_id: &str) -> Result<(), String>
pub async fn set_locale(&self, locale: &str) -> Result<(), String>
pub async fn set_geolocation( &self, latitude: f64, longitude: f64, accuracy: Option<f64>, ) -> Result<(), String>
pub async fn grant_permissions( &self, permissions: &[String], ) -> Result<(), String>
pub async fn handle_dialog( &self, accept: bool, prompt_text: Option<&str>, ) -> Result<(), String>
pub async fn upload_files( &self, selector: &str, files: &[String], ref_map: &RefMap, iframe_sessions: &HashMap<String, String>, ) -> Result<(), String>
pub async fn add_script_to_evaluate( &self, source: &str, ) -> Result<String, String>
pub async fn remove_script_to_evaluate( &self, identifier: &str, ) -> Result<(), String>
pub async fn tab_switch_by_id(&mut self, tab_id: u32) -> Result<Value, String>
pub async fn tab_close_by_id( &mut self, tab_id: Option<u32>, ) -> Result<Value, String>
pub fn assign_tab_id(&mut self) -> u32
pub fn add_page(&mut self, page: PageInfo)
pub fn update_page_target_info(&mut self, target: &TargetInfo) -> bool
pub fn remove_page_by_target_id(&mut self, target_id: &str)
pub fn has_target(&self, target_id: &str) -> bool
pub fn page_count(&self) -> usize
Sourcepub fn active_tab_id(&self) -> Option<u32>
pub fn active_tab_id(&self) -> Option<u32>
Returns the stable tab_id of the currently active page, if any.
Sourcepub fn has_tab_id(&self, tab_id: u32) -> bool
pub fn has_tab_id(&self, tab_id: u32) -> bool
Returns true if a tab with the given stable tab_id is still open.
pub fn pages_list(&self) -> Vec<PageInfo>
pub fn visited_origins(&self) -> &HashSet<String>
pub async fn set_download_behavior( &self, download_path: &str, ) -> Result<(), String>
Auto Trait Implementations§
impl !RefUnwindSafe for BrowserManager
impl !UnwindSafe for BrowserManager
impl Freeze for BrowserManager
impl Send for BrowserManager
impl Sync for BrowserManager
impl Unpin for BrowserManager
impl UnsafeUnpin for BrowserManager
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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