Skip to main content

BrowserManager

Struct BrowserManager 

Source
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: bool

Whether to ignore HTTPS certificate errors, re-applied to new contexts (e.g., recording)

Implementations§

Source§

impl BrowserManager

Source

pub fn chrome_pid(&self) -> Option<u32>

OS pid of the launched Chrome process, if this manager owns one.

Source

pub async fn launch( options: LaunchOptions, engine: Option<&str>, ) -> Result<Self, String>

Source

pub async fn enable_domains_pub(&self, session_id: &str) -> Result<(), String>

Source

pub async fn prepare_domains_pub(&self, session_id: &str) -> Result<(), String>

Source

pub async fn resume_if_waiting_pub( &self, session_id: &str, ) -> Result<(), String>

Source

pub async fn enable_browser_auto_attach_pub(&self) -> Result<(), String>

Source

pub fn active_session_id(&self) -> Result<&str, String>

Source

pub async fn navigate( &mut self, url: &str, wait_until: WaitUntil, ) -> Result<Value, String>

Source

pub async fn get_url(&self) -> Result<String, String>

Source

pub async fn get_title(&self) -> Result<String, String>

Source

pub async fn get_content(&self) -> Result<String, String>

Source

pub async fn evaluate( &self, script: &str, _args: Option<Value>, ) -> Result<Value, String>

Source

pub async fn wait_for_lifecycle_external( &self, wait_until: WaitUntil, session_id: &str, ) -> Result<(), String>

Source

pub async fn close(&mut self) -> Result<(), String>

Source

pub fn has_pages(&self) -> bool

Source

pub fn default_timeout_ms(&self) -> u64

Source

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.

Source

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).

Source

pub fn get_cdp_url(&self) -> &str

Source

pub fn chrome_host_port(&self) -> &str

Returns the Chrome debug server address as “host:port”.

Source

pub fn active_target_id(&self) -> Result<&str, String>

Source

pub fn is_cdp_connection(&self) -> bool

Returns true if this manager was connected via CDP (as opposed to local launch).

Source

pub fn is_direct_page_connection(&self) -> bool

Source

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.

Source

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).

Source

pub fn tab_list(&self) -> Vec<Value>

Source

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.

Source

pub fn has_label(&self, label: &str) -> bool

Returns true iff a tab already carries the given label.

Source

pub async fn tab_new( &mut self, url: Option<&str>, label: Option<&str>, ) -> Result<Value, String>

Source

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).

Source

pub async fn create_browser_context(&self) -> Result<String, String>

Create an isolated BrowserContext and return its id.

Source

pub async fn tab_switch(&mut self, index: usize) -> Result<Value, String>

Source

pub async fn tab_close(&mut self, index: Option<usize>) -> Result<Value, String>

Source

pub async fn set_viewport( &self, width: i32, height: i32, device_scale_factor: f64, mobile: bool, ) -> Result<(), String>

Source

pub async fn set_user_agent(&self, user_agent: &str) -> Result<(), String>

Source

pub async fn set_emulated_media( &self, media: Option<&str>, features: Option<Vec<(String, String)>>, ) -> Result<(), String>

Source

pub async fn bring_to_front(&self) -> Result<(), String>

Source

pub async fn set_timezone(&self, timezone_id: &str) -> Result<(), String>

Source

pub async fn set_locale(&self, locale: &str) -> Result<(), String>

Source

pub async fn set_geolocation( &self, latitude: f64, longitude: f64, accuracy: Option<f64>, ) -> Result<(), String>

Source

pub async fn grant_permissions( &self, permissions: &[String], ) -> Result<(), String>

Source

pub async fn handle_dialog( &self, accept: bool, prompt_text: Option<&str>, ) -> Result<(), String>

Source

pub async fn upload_files( &self, selector: &str, files: &[String], ref_map: &RefMap, iframe_sessions: &HashMap<String, String>, ) -> Result<(), String>

Source

pub async fn add_script_to_evaluate( &self, source: &str, ) -> Result<String, String>

Source

pub async fn remove_script_to_evaluate( &self, identifier: &str, ) -> Result<(), String>

Source

pub async fn tab_switch_by_id(&mut self, tab_id: u32) -> Result<Value, String>

Source

pub async fn tab_close_by_id( &mut self, tab_id: Option<u32>, ) -> Result<Value, String>

Source

pub fn assign_tab_id(&mut self) -> u32

Source

pub fn add_page(&mut self, page: PageInfo)

Source

pub fn update_page_target_info(&mut self, target: &TargetInfo) -> bool

Source

pub fn remove_page_by_target_id(&mut self, target_id: &str)

Source

pub fn has_target(&self, target_id: &str) -> bool

Source

pub fn page_count(&self) -> usize

Source

pub fn active_tab_id(&self) -> Option<u32>

Returns the stable tab_id of the currently active page, if any.

Source

pub fn has_tab_id(&self, tab_id: u32) -> bool

Returns true if a tab with the given stable tab_id is still open.

Source

pub fn pages_list(&self) -> Vec<PageInfo>

Source

pub fn visited_origins(&self) -> &HashSet<String>

Source

pub async fn set_download_behavior( &self, download_path: &str, ) -> Result<(), String>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more