Skip to main content

Browser

Struct Browser 

Source
pub struct Browser { /* private fields */ }
Expand description

Browser session for managing CDP connections

Implementations§

Source§

impl Browser

Source

pub fn new(profile: BrowserProfile) -> Self

Create a new Browser session with given profile

Source

pub fn with_cdp_url(self, cdp_url: String) -> Self

Set CDP URL to connect to existing browser instead of launching new one

Source

pub async fn start(&mut self) -> Result<()>

Start the browser session (launches browser or connects to existing)

Source

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

Navigate to the specified URL

Source

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

Get the current page URL

Source

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_dir pointing 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.

Source

pub fn get_cdp_client(&self) -> Result<Arc<CdpClient>>

Get the CDP client for the current session

Source

pub fn get_session_id(&self) -> Result<String>

Get the session ID for the current target

Source

pub fn get_page(&self) -> Result<Page>

Get a Page actor for the current session

Source

pub fn get_current_target_id(&self) -> Result<String>

Get the current target ID

Source

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

Source

pub async fn get_tabs(&self) -> Result<Vec<TabInfo>>

Get all open tabs

Source

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

Create a new tab

Source

pub async fn switch_to_tab(&mut self, target_id: &str) -> Result<()>

Switch to a different tab by target ID

Source

pub async fn close_tab(&mut self, target_id: &str) -> Result<()>

Close a tab by target ID

Source

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)

Source

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

Get the current page title

Source

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

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,

Start the browser session
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,

Stop the browser session and clean up resources gracefully. Default does nothing (for mocks or external browsers we don’t own).
Source§

fn navigate<'life0, 'life1, 'async_trait>( &'life0 mut self, url: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Navigate to the specified URL
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,

Get the current page URL
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,

Create a new tab with optional URL
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,

Switch to a different tab by target ID
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,

Close a tab by target ID
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,

Get all open tabs
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,

Get target ID from short tab ID (last 4 characters)
Source§

fn get_page(&self) -> Result<Page>

Get a Page actor for the current session
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,

Take a screenshot of the current page
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,

👎Deprecated since 0.1.2: Use get_session_info() instead
Get the current page title
Source§

fn get_cdp_client(&self) -> Result<Arc<CdpClient>>

Get the CDP client for the current session
Source§

fn get_session_id(&self) -> Result<String>

👎Deprecated since 0.1.2: Use get_session_info() instead
Get the session ID for the current target
Source§

fn get_current_target_id(&self) -> Result<String>

👎Deprecated since 0.1.2: Use get_session_info() instead
Get the current target ID
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,

Get streamlined session information (URL, title, target ID, session ID)

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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: 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