protocol/target
⚙️ This module was generated from the Chrome DevTools Protocol version 1.3
Target Domain
Supports additional targets discovery and allows to attach to them.
📖 View this domain on the DevTools Protocol API Docs
Types
This type is not part of the protocol spec, it has been generated dynamically
to represent the response to the command attach_to_target
pub type AttachToTargetResponse {
AttachToTargetResponse(session_id: SessionID)
}
Constructors
-
AttachToTargetResponse(session_id: SessionID)
Arguments
-
session_id
Id assigned to the session.
-
This type is not part of the protocol spec, it has been generated dynamically
to represent the response to the command create_browser_context
pub type CreateBrowserContextResponse {
CreateBrowserContextResponse(browser_context_id: String)
}
Constructors
-
CreateBrowserContextResponse(browser_context_id: String)
Arguments
-
browser_context_id
The id of the context created.
-
This type is not part of the protocol spec, it has been generated dynamically
to represent the response to the command create_target
pub type CreateTargetResponse {
CreateTargetResponse(target_id: TargetID)
}
Constructors
-
CreateTargetResponse(target_id: TargetID)
Arguments
-
target_id
The id of the page opened.
-
This type is not part of the protocol spec, it has been generated dynamically
to represent the response to the command get_browser_contexts
pub type GetBrowserContextsResponse {
GetBrowserContextsResponse(browser_context_ids: List(String))
}
Constructors
-
GetBrowserContextsResponse(browser_context_ids: List(String))
Arguments
-
browser_context_ids
An array of browser context ids.
-
This type is not part of the protocol spec, it has been generated dynamically
to represent the response to the command get_targets
pub type GetTargetsResponse {
GetTargetsResponse(target_infos: List(TargetInfo))
}
Constructors
-
GetTargetsResponse(target_infos: List(TargetInfo))
Arguments
-
target_infos
The list of targets.
-
Unique identifier of attached debugging session.
pub type SessionID {
SessionID(String)
}
Constructors
-
SessionID(String)
pub type TargetInfo {
TargetInfo(
target_id: TargetID,
type_: String,
title: String,
url: String,
attached: Bool,
opener_id: option.Option(TargetID),
)
}
Constructors
-
TargetInfo( target_id: TargetID, type_: String, title: String, url: String, attached: Bool, opener_id: option.Option(TargetID), )
Arguments
-
type_
List of types: https://source.chromium.org/chromium/chromium/src/+/main:content/browser/devtools/devtools_agent_host_impl.cc?ss=chromium&q=f:devtools%20-f:out%20%22::kTypeTab%5B%5D%22
-
attached
Whether the target has an attached client.
-
opener_id
Opener target Id
-
Functions
pub fn activate_target(
callback__: fn(String, Option(Json)) -> a,
target_id target_id: TargetID,
) -> a
Activates (focuses) the target.
Parameters:
target_id
Returns:
pub fn attach_to_target(
callback__: fn(String, Option(Json)) ->
Result(Dynamic, RequestError),
target_id target_id: TargetID,
flatten flatten: Option(Bool),
) -> Result(AttachToTargetResponse, RequestError)
Attaches to the target with given id.
Parameters:
target_id
flatten
: Enables “flat” access to the session via specifying sessionId attribute in the commands. We plan to make this the default, deprecate non-flattened mode, and eventually retire it. See crbug.com/991325.
Returns:
session_id
: Id assigned to the session.
pub fn close_target(
callback__: fn(String, Option(Json)) -> a,
target_id target_id: TargetID,
) -> a
Closes the target. If the target is a page that gets closed too.
Parameters:
target_id
Returns:
pub fn create_browser_context(
callback__: fn(String, Option(a)) ->
Result(Dynamic, RequestError),
) -> Result(CreateBrowserContextResponse, RequestError)
Creates a new empty BrowserContext. Similar to an incognito profile but you can have more than one.
Parameters:
Returns:
browser_context_id
: The id of the context created.
pub fn create_target(
callback__: fn(String, Option(Json)) ->
Result(Dynamic, RequestError),
url url: String,
width width: Option(Int),
height height: Option(Int),
new_window new_window: Option(Bool),
background background: Option(Bool),
) -> Result(CreateTargetResponse, RequestError)
Creates a new page.
Parameters:
url
: The initial URL the page will be navigated to. An empty string indicates about:blank.width
: Frame width in DIP (headless chrome only).height
: Frame height in DIP (headless chrome only).new_window
: Whether to create a new Window or Tab (chrome-only, false by default).background
: Whether to create the target in background or foreground (chrome-only, false by default).
Returns:
target_id
: The id of the page opened.
pub fn detach_from_target(
callback__: fn(String, Option(Json)) -> a,
session_id session_id: Option(SessionID),
) -> a
Detaches session with given id.
Parameters:
session_id
: Session to detach.
Returns:
pub fn dispose_browser_context(
callback__: fn(String, Option(Json)) -> a,
browser_context_id browser_context_id: String,
) -> a
Deletes a BrowserContext. All the belonging pages will be closed without calling their beforeunload hooks.
Parameters:
browser_context_id
Returns:
pub fn get_browser_contexts(
callback__: fn(String, Option(a)) ->
Result(Dynamic, RequestError),
) -> Result(GetBrowserContextsResponse, RequestError)
Returns all browser contexts created with Target.createBrowserContext
method.
browser_context_ids
: An array of browser context ids.
pub fn get_targets(
callback__: fn(String, Option(a)) ->
Result(Dynamic, RequestError),
) -> Result(GetTargetsResponse, RequestError)
Retrieves a list of available targets.
Parameters:
Returns:
target_infos
: The list of targets.
pub fn set_auto_attach(
callback__: fn(String, Option(Json)) -> a,
auto_attach auto_attach: Bool,
wait_for_debugger_on_start wait_for_debugger_on_start: Bool,
) -> a
Controls whether to automatically attach to new targets which are considered to be related to
this one. 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.
Parameters:
auto_attach
: Whether to auto-attach to related targets.wait_for_debugger_on_start
: Whether to pause new targets when attaching to them. UseRuntime.runIfWaitingForDebugger
to run paused targets.
Returns:
pub fn set_discover_targets(
callback__: fn(String, Option(Json)) -> a,
discover discover: Bool,
) -> a
Controls whether to discover available targets and notify via
targetCreated/targetInfoChanged/targetDestroyed
events.
Parameters:
discover
: Whether to discover available targets.
Returns: