CDPotion.Domain.Target (cdpotion v0.1.4)
Summary
Types
A filter used by target query/discovery/auto-attach operations.
description not provided :(
Unique identifier of attached debugging session.
The entries in TargetFilter are matched sequentially against targets and
the first entry that matches determines if the target is included or not,
depending on the value of exclude
field in the entry.
If filter is not specified, the one assumed is
[{type: 'browser', exclude: true}, {type: 'tab', exclude: true}, {}]
(i.e. include everything but browser
and tab
).
description not provided :(
description not provided :(
Functions
Activates (focuses) the target.
Attaches to the browser target, only uses flat sessionId mode.
Attaches to the target with given id.
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.
Closes the target. If the target is a page that gets closed too.
Creates a new empty BrowserContext. Similar to an incognito profile but you can have more than one.
Creates a new page.
Detaches session with given id.
Deletes a BrowserContext. All the belonging pages will be closed without calling their beforeunload hooks.
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 follwing API
Returns all browser contexts created with Target.createBrowserContext
method.
Returns information about a target.
Retrieves a list of available targets.
Sends protocol message over session with given id. Consider using flat mode instead; see commands attachToTarget, setAutoAttach, and crbug.com/991325.
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.
Controls whether to discover available targets and notify via
targetCreated/targetInfoChanged/targetDestroyed
events.
Enables target discovery for the specified locations, when setDiscoverTargets
was set to
true
.
Types
filter_entry()
A filter used by target query/discovery/auto-attach operations.
remote_location()
description not provided :(
session_id()
@type session_id() :: String.t()
Unique identifier of attached debugging session.
target_filter()
@type target_filter() :: [filter_entry()]
The entries in TargetFilter are matched sequentially against targets and
the first entry that matches determines if the target is included or not,
depending on the value of exclude
field in the entry.
If filter is not specified, the one assumed is
[{type: 'browser', exclude: true}, {type: 'tab', exclude: true}, {}]
(i.e. include everything but browser
and tab
).
target_id()
@type target_id() :: String.t()
description not provided :(
target_info()
@type target_info() :: %{ attached: boolean(), browserContextId: CDPotion.Domain.Browser.browser_context_id() | nil, canAccessOpener: boolean(), openerFrameId: CDPotion.Domain.Page.frame_id() | nil, openerId: target_id() | nil, subtype: String.t() | nil, targetId: target_id(), title: String.t(), type: String.t(), url: String.t() }
description not provided :(
Functions
activate_target(target_id)
Activates (focuses) the target.
Parameters:
- (Required)
target_id
: description not provided :(
attach_to_browser_target()
Attaches to the browser target, only uses flat sessionId mode.
attach_to_target(target_id, flatten \\ nil)
Attaches to the target with given id.
Parameters:
- (Required)
target_id
: description not provided :( - (Optional)
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.
close_target(target_id)
Closes the target. If the target is a page that gets closed too.
Parameters:
- (Required)
target_id
: description not provided :(
create_browser_context(dispose_on_detach \\ nil, proxy_server \\ nil, proxy_bypass_list \\ nil, origins_with_universal_network_access \\ nil)
@spec create_browser_context(boolean(), String.t(), String.t(), [String.t()]) :: {String.t(), map()}
Creates a new empty BrowserContext. Similar to an incognito profile but you can have more than one.
Parameters:
- (Optional)
dispose_on_detach
: If specified, disposes this context when debugging session disconnects. - (Optional)
proxy_server
: Proxy server, similar to the one passed to --proxy-server - (Optional)
proxy_bypass_list
: Proxy bypass list, similar to the one passed to --proxy-bypass-list - (Optional)
origins_with_universal_network_access
: An optional list of origins to grant unlimited cross-origin access to. Parts of the URL other than those constituting origin are ignored.
create_target(url, width \\ nil, height \\ nil, browser_context_id \\ nil, enable_begin_frame_control \\ nil, new_window \\ nil, background \\ nil, for_tab \\ nil)
@spec create_target( String.t(), integer(), integer(), CDPotion.Domain.Browser.browser_context_id(), boolean(), boolean(), boolean(), boolean() ) :: {String.t(), map()}
Creates a new page.
Parameters:
- (Required)
url
: The initial URL the page will be navigated to. An empty string indicates about:blank. - (Optional)
width
: Frame width in DIP (headless chrome only). - (Optional)
height
: Frame height in DIP (headless chrome only). - (Optional)
browser_context_id
: The browser context to create the page in. - (Optional)
enable_begin_frame_control
: Whether BeginFrames for this target will be controlled via DevTools (headless chrome only, not supported on MacOS yet, false by default). - (Optional)
new_window
: Whether to create a new Window or Tab (chrome-only, false by default). - (Optional)
background
: Whether to create the target in background or foreground (chrome-only, false by default). - (Optional)
for_tab
: Whether to create the target of type "tab".
detach_from_target(session_id \\ nil, target_id \\ nil)
@spec detach_from_target( session_id(), target_id() ) :: {String.t(), map()}
Detaches session with given id.
Parameters:
- (Optional)
session_id
: Session to detach. - (Optional)
target_id
: Deprecated.
dispose_browser_context(browser_context_id)
@spec dispose_browser_context(CDPotion.Domain.Browser.browser_context_id()) :: {String.t(), map()}
Deletes a BrowserContext. All the belonging pages will be closed without calling their beforeunload hooks.
Parameters:
- (Required)
browser_context_id
: description not provided :(
expose_dev_tools_protocol(target_id, binding_name \\ nil)
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 follwing API:
binding.send(json)
- a method to send messages over the remote debugging protocolbinding.onmessage = json => handleMessage(json)
- a callback that will be called for the protocol notifications and command responses.
Parameters:
- (Required)
target_id
: description not provided :( - (Optional)
binding_name
: Binding name, 'cdp' if not specified.
get_browser_contexts()
Returns all browser contexts created with Target.createBrowserContext
method.
get_target_info(target_id \\ nil)
Returns information about a target.
Parameters:
- (Optional)
target_id
: description not provided :(
get_targets(filter \\ nil)
@spec get_targets(target_filter()) :: {String.t(), map()}
Retrieves a list of available targets.
Parameters:
- (Optional)
filter
: Only targets matching filter will be reported. If filter is not specified and target discovery is currently enabled, a filter used for target discovery is used for consistency.
send_message_to_target(message, session_id \\ nil, target_id \\ nil)
@spec send_message_to_target( String.t(), session_id(), target_id() ) :: {String.t(), map()}
Sends protocol message over session with given id. Consider using flat mode instead; see commands attachToTarget, setAutoAttach, and crbug.com/991325.
Parameters:
- (Required)
message
: description not provided :( - (Optional)
session_id
: Identifier of the session. - (Optional)
target_id
: Deprecated.
set_auto_attach(auto_attach, wait_for_debugger_on_start, flatten \\ nil, filter \\ nil)
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:
- (Required)
auto_attach
: Whether to auto-attach to related targets. - (Required)
wait_for_debugger_on_start
: Whether to pause new targets when attaching to them. UseRuntime.runIfWaitingForDebugger
to run paused targets. - (Optional)
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. - (Optional)
filter
: Only targets matching filter will be attached.
set_discover_targets(discover, filter \\ nil)
@spec set_discover_targets(boolean(), target_filter()) :: {String.t(), map()}
Controls whether to discover available targets and notify via
targetCreated/targetInfoChanged/targetDestroyed
events.
Parameters:
- (Required)
discover
: Whether to discover available targets. - (Optional)
filter
: Only targets matching filter will be attached. Ifdiscover
is false,filter
must be omitted or empty.
set_remote_locations(locations)
@spec set_remote_locations([remote_location()]) :: {String.t(), map()}
Enables target discovery for the specified locations, when setDiscoverTargets
was set to
true
.
Parameters:
- (Required)
locations
: List of remote locations.