Skip to main content

CdpClient

Struct CdpClient 

Source
pub struct CdpClient { /* private fields */ }

Implementations§

Source§

impl CdpClient

Source

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

Source

pub fn set_command_timeout(&self, timeout: Duration)

Set the per-command timeout applied to every send_command call. Passing a zero duration disables the timeout (commands wait indefinitely).

Source

pub fn command_timeout(&self) -> Duration

The current per-command timeout.

Source

pub fn subscribe_events(&self) -> Receiver<(String, Value)>

Source

pub async fn wait_for_event( &self, method: &str, timeout_ms: u64, ) -> Result<Value>

Source

pub async fn enable_domain(&self, domain: &str) -> Result<()>

Source

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

Source

pub async fn navigate_and_wait( &self, url: &str, timeout_ms: u64, ) -> Result<NavigationResult>

Source

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

Source

pub async fn evaluate(&self, expression: &str) -> Result<EvaluateResult>

Source

pub async fn get_document(&self) -> Result<DocumentNode>

Source

pub async fn query_selector( &self, node_id: i64, selector: &str, ) -> Result<Option<i64>>

Returns the matched nodeId, or None when nothing matches. CDP reports a missing match as nodeId 0; this surfaces that as None rather than a node id that looks valid.

Source

pub async fn get_outer_html(&self, node_id: i64) -> Result<String>

Source

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

Source

pub async fn screenshot(&self) -> Result<Vec<u8>>

Source

pub async fn screenshot_to_file(&self, path: &str) -> Result<()>

Source

pub async fn full_page_screenshot(&self) -> Result<Vec<u8>>

Source

pub async fn full_page_screenshot_to_file(&self, path: &str) -> Result<()>

Source

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

Source

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

Source

pub async fn get_version(host: &str, port: u16) -> Result<BrowserVersion>

Source

pub async fn list_targets(host: &str, port: u16) -> Result<Vec<Target>>

Source

pub async fn connect_to_page(host: &str, port: u16) -> Result<Self>

Source

pub async fn create_tab( host: &str, port: u16, url: Option<&str>, ) -> Result<Target>

Source§

impl CdpClient

Source

pub async fn delete_cookies(&self, name: &str, url: Option<&str>) -> Result<()>

Source

pub async fn set_extra_headers( &self, headers: &HashMap<String, String>, ) -> Result<()>

Source

pub async fn block_urls(&self, patterns: &[&str]) -> Result<()>

Source

pub async fn get_response_body(&self, request_id: &str) -> Result<String>

Source

pub async fn intercept_requests(&self, url_patterns: &[&str]) -> Result<()>

Source

pub async fn continue_request(&self, request_id: &str) -> Result<()>

Source

pub async fn fulfill_request( &self, request_id: &str, status: u16, body: &str, content_type: &str, ) -> Result<()>

Source§

impl CdpClient

Source

pub async fn set_content(&self, html: &str) -> Result<()>

Source

pub async fn print_to_pdf(&self, path: &str) -> Result<()>

Source

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

Source

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

Source

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

Source

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

Source

pub async fn set_offline(&self, offline: bool) -> Result<()>

Source

pub async fn set_attribute( &self, node_id: i64, name: &str, value: &str, ) -> Result<()>

Source

pub async fn set_outer_html(&self, node_id: i64, html: &str) -> Result<()>

Source

pub async fn remove_node(&self, node_id: i64) -> Result<()>

Source

pub async fn call_function_on( &self, object_id: &str, function_declaration: &str, ) -> Result<Value>

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