BrowserSession

Struct BrowserSession 

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

Browser session that manages a Chrome/Chromium instance

Implementations§

Source§

impl BrowserSession

Source

pub fn launch(options: LaunchOptions) -> Result<Self>

Launch a new browser instance with the given options

Source

pub fn connect(options: ConnectionOptions) -> Result<Self>

Connect to an existing browser instance via WebSocket

Source

pub fn new() -> Result<Self>

Launch a browser with default options

Source

pub fn tab(&self) -> &Arc<Tab>

Get the active tab

Source

pub fn new_tab(&mut self) -> Result<Arc<Tab>>

Create a new tab and set it as active

Source

pub fn switch_tab(&mut self, index: usize) -> Result<()>

Switch to a specific tab by index

Source

pub fn get_tabs(&self) -> Result<Vec<Arc<Tab>>>

Get all tabs

Source

pub fn close_active_tab(&mut self) -> Result<()>

Close the active tab

Source

pub fn browser(&self) -> &Browser

Get the underlying Browser instance

Source

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

Navigate to a URL using the active tab

Source

pub fn wait_for_navigation(&self) -> Result<()>

Wait for navigation to complete

Source

pub fn extract_dom(&self) -> Result<DomTree>

Extract the DOM tree from the active tab

Source

pub fn extract_simplified_dom(&self) -> Result<DomTree>

Extract and simplify the DOM tree from the active tab

Source

pub fn find_element<'a>(&'a self, css_selector: &str) -> Result<Element<'a>>

Get element selector by index from the last extracted DOM Note: You need to extract the DOM first using extract_dom()

Source

pub fn tool_registry(&self) -> &ToolRegistry

Get the tool registry

Source

pub fn tool_registry_mut(&mut self) -> &mut ToolRegistry

Get mutable tool registry

Source

pub fn execute_tool(&self, name: &str, params: Value) -> Result<ToolResult>

Execute a tool by name

Source

pub fn go_back(&self) -> Result<()>

Navigate back in browser history

Source

pub fn go_forward(&self) -> Result<()>

Navigate forward in browser history

Source

pub fn close(&self) -> Result<()>

Close the browser

Trait Implementations§

Source§

impl Default for BrowserSession

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,