Skip to main content

TargetClient

Struct TargetClient 

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

Client for Target domain commands.

Implementations§

Source§

impl TargetClient

Source

pub async fn activate_target( &self, params: ActivateTargetParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Activates (focuses) the target.

Source

pub async fn attach_to_target( &self, params: AttachToTargetParams, session_id: Option<&str>, ) -> Result<AttachToTargetReturns, CdpError>

Attaches to the target with given id.

Source

pub async fn attach_to_browser_target( &self, session_id: Option<&str>, ) -> Result<AttachToBrowserTargetReturns, CdpError>

Attaches to the browser target, only uses flat sessionId mode.

Source

pub async fn close_target( &self, params: CloseTargetParams, session_id: Option<&str>, ) -> Result<CloseTargetReturns, CdpError>

Closes the target. If the target is a page that gets closed too.

Source

pub async fn expose_dev_tools_protocol( &self, params: ExposeDevToolsProtocolParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Inject object to the target’s main frame that provides a communication channel with browser target.

Injected object will be available as window[bindingName].

The object has the following API:

  • binding.send(json) - a method to send messages over the remote debugging protocol
  • binding.onmessage = json => handleMessage(json) - a callback that will be called for the protocol notifications and command responses.
Source

pub async fn create_browser_context( &self, params: CreateBrowserContextParams, session_id: Option<&str>, ) -> Result<CreateBrowserContextReturns, CdpError>

Creates a new empty BrowserContext. Similar to an incognito profile but you can have more than one.

Source

pub async fn get_browser_contexts( &self, session_id: Option<&str>, ) -> Result<GetBrowserContextsReturns, CdpError>

Returns all browser contexts created with Target.createBrowserContext method.

Source

pub async fn create_target( &self, params: CreateTargetParams, session_id: Option<&str>, ) -> Result<CreateTargetReturns, CdpError>

Creates a new page.

Source

pub async fn detach_from_target( &self, params: DetachFromTargetParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Detaches session with given id.

Source

pub async fn dispose_browser_context( &self, params: DisposeBrowserContextParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Deletes a BrowserContext. All the belonging pages will be closed without calling their beforeunload hooks.

Source

pub async fn get_target_info( &self, params: GetTargetInfoParams, session_id: Option<&str>, ) -> Result<GetTargetInfoReturns, CdpError>

Returns information about a target.

Source

pub async fn get_targets( &self, params: GetTargetsParams, session_id: Option<&str>, ) -> Result<GetTargetsReturns, CdpError>

Retrieves a list of available targets.

Source

pub async fn send_message_to_target( &self, params: SendMessageToTargetParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Sends protocol message over session with given id. Consider using flat mode instead; see commands attachToTarget, setAutoAttach, and crbug.com/991325.

Source

pub async fn set_auto_attach( &self, params: SetAutoAttachParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Controls whether to automatically attach to new targets which are considered to be directly related to this one (for example, iframes or workers). When turned on, attaches to all existing related targets as well. When turned off, automatically detaches from all currently attached targets. This also clears all targets added by autoAttachRelated from the list of targets to watch for creation of related targets. You might want to call this recursively for auto-attached targets to attach to all available targets.

Adds the specified target to the list of targets that will be monitored for any related target creation (such as child frames, child workers and new versions of service worker) and reported through attachedToTarget. The specified target is also auto-attached. This cancels the effect of any previous setAutoAttach and is also cancelled by subsequent setAutoAttach. Only available at the Browser target.

Source

pub async fn set_discover_targets( &self, params: SetDiscoverTargetsParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Controls whether to discover available targets and notify via targetCreated/targetInfoChanged/targetDestroyed events.

Source

pub async fn set_remote_locations( &self, params: SetRemoteLocationsParams, session_id: Option<&str>, ) -> Result<Value, CdpError>

Enables target discovery for the specified locations, when setDiscoverTargets was set to true.

Source

pub async fn get_dev_tools_target( &self, params: GetDevToolsTargetParams, session_id: Option<&str>, ) -> Result<GetDevToolsTargetReturns, CdpError>

Gets the targetId of the DevTools page target opened for the given target (if any).

Source

pub async fn open_dev_tools( &self, params: OpenDevToolsParams, session_id: Option<&str>, ) -> Result<OpenDevToolsReturns, CdpError>

Opens a DevTools window for the target.

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