Skip to main content

Browser

Struct Browser 

Source
pub struct Browser {
    pub user_agent: String,
    /* private fields */
}
Expand description

A browser-level CDP connection used to drive one page inside an isolated browser context (Target.createBrowserContext): its own cookie jar and storage, shared with no other tab, so nothing else in the browser can log it out and it can’t disturb the user’s tabs.

Contexts are created with disposeOnDetach: false, so the context and its tab survive this process exiting; a later process reconnects by id.

Fields§

§user_agent: String

The browser’s User-Agent.

Implementations§

Source§

impl Browser

Source

pub async fn connect(base: &str) -> Result<Self>

Source

pub async fn call( &mut self, session: Option<&str>, method: &str, params: Value, ) -> Result<Value>

Raw CDP call, optionally on an attached page session.

Source

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

Create an isolated context that outlives this connection.

Source

pub async fn context_exists(&mut self, context: &str) -> Result<bool>

Source

pub async fn dispose_context(&mut self, context: &str) -> Result<()>

Dispose a context we created (closes its tabs, drops its cookies).

Source

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

Open url in a new background tab of context.

Source

pub async fn tab_in_context( &mut self, context: &str, target: &str, ) -> Result<bool>

Whether target is still a page in context.

Source

pub async fn attach(&mut self, target: &str) -> Result<String>

Attach to a tab (flattened session) and make it behave like a focused, visible page: a background tab otherwise never runs requestAnimationFrame, and the login SPA stays on its spinner.

Source

pub async fn eval(&mut self, session: &str, expression: &str) -> Result<Value>

Evaluate expression in the page (promises awaited) and return its JSON value. Callers must not log values that are credentials.

Source

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

Navigate the attached page.

Source

pub async fn click_at(&mut self, session: &str, x: f64, y: f64) -> Result<()>

A trusted left click at viewport coordinates (as a user’s would be).

Source

pub async fn type_digits(&mut self, session: &str, digits: &str) -> Result<()>

Type ASCII digits into the focused element, one key at a time.

Source

pub async fn context_cookies(&mut self, context: &str) -> Result<Vec<Cookie>>

The grab.com cookies of one browser context.

Source

pub async fn default_cookies(&mut self) -> Result<Vec<Cookie>>

The grab.com cookies of the browser’s default context (the user’s normal tabs), as opposed to context_cookies.

Source

pub async fn drain_events(&mut self, wait: Duration) -> Result<usize>

Drain buffered CDP events (e.g. after a navigation), waiting up to wait for more. Returns how many were seen.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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