TargetApi class
Supports additional targets discovery and allows to attach to them.
Constructors
- TargetApi(Client _client)
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
onAttachedToTarget
→ Stream<
AttachedToTargetEvent> -
Issued when attached to target because of auto-attach or
attachToTarget
command.no setter -
onDetachedFromTarget
→ Stream<
DetachedFromTargetEvent> -
Issued when detached from target for any reason (including
detachFromTarget
command). Can be issued multiple times per target if multiple sessions have been attached to it.no setter -
onReceivedMessageFromTarget
→ Stream<
ReceivedMessageFromTargetEvent> -
Notifies about a new protocol message received from the session (as reported in
attachedToTarget
event).no setter -
onTargetCrashed
→ Stream<
TargetCrashedEvent> -
Issued when a target has crashed.
no setter
-
onTargetCreated
→ Stream<
TargetInfo> -
Issued when a possible inspection target is created.
no setter
-
onTargetDestroyed
→ Stream<
TargetID> -
Issued when a target is destroyed.
no setter
-
onTargetInfoChanged
→ Stream<
TargetInfo> -
Issued when some information about a target has changed. This only happens between
targetCreated
andtargetDestroyed
.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
activateTarget(
TargetID targetId) → Future< void> - Activates (focuses) the target.
-
attachToBrowserTarget(
) → Future< SessionID> - Attaches to the browser target, only uses flat sessionId mode. Returns: Id assigned to the session.
-
attachToTarget(
TargetID targetId, {bool? flatten}) → Future< SessionID> -
Attaches to the target with given 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: Id assigned to the session. -
autoAttachRelated(
TargetID targetId, bool waitForDebuggerOnStart, {TargetFilter? filter}) → Future< void> -
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 previoussetAutoAttach
and is also cancelled by subsequentsetAutoAttach
. Only available at the Browser target.waitForDebuggerOnStart
Whether to pause new targets when attaching to them. UseRuntime.runIfWaitingForDebugger
to run paused targets.filter
Only targets matching filter will be attached. -
closeTarget(
TargetID targetId) → Future< bool> - Closes the target. If the target is a page that gets closed too. Returns: Always set to true. If an error occurs, the response indicates protocol error.
-
createBrowserContext(
{bool? disposeOnDetach, String? proxyServer, String? proxyBypassList, List< String> ? originsWithUniversalNetworkAccess}) → Future<BrowserContextID> -
Creates a new empty BrowserContext. Similar to an incognito profile but you can have more than
one.
disposeOnDetach
If specified, disposes this context when debugging session disconnects.proxyServer
Proxy server, similar to the one passed to --proxy-serverproxyBypassList
Proxy bypass list, similar to the one passed to --proxy-bypass-listoriginsWithUniversalNetworkAccess
An optional list of origins to grant unlimited cross-origin access to. Parts of the URL other than those constituting origin are ignored. Returns: The id of the context created. -
createTarget(
String url, {int? width, int? height, BrowserContextID? browserContextId, bool? enableBeginFrameControl, bool? newWindow, bool? background, bool? forTab}) → Future< TargetID> -
Creates a new page.
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).browserContextId
The browser context to create the page in.enableBeginFrameControl
Whether BeginFrames for this target will be controlled via DevTools (headless chrome only, not supported on MacOS yet, false by default).newWindow
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).forTab
Whether to create the target of type "tab". Returns: The id of the page opened. -
detachFromTarget(
{SessionID? sessionId, TargetID? targetId}) → Future< void> -
Detaches session with given id.
sessionId
Session to detach. -
disposeBrowserContext(
BrowserContextID browserContextId) → Future< void> - Deletes a BrowserContext. All the belonging pages will be closed without calling their beforeunload hooks.
-
exposeDevToolsProtocol(
TargetID targetId, {String? bindingName}) → Future< void> - Inject object to the target's main frame that provides a communication channel with browser target.
-
getBrowserContexts(
) → Future< List< BrowserContextID> > -
Returns all browser contexts created with
Target.createBrowserContext
method. Returns: An array of browser context ids. -
getTargetInfo(
{TargetID? targetId}) → Future< TargetInfo> - Returns information about a target.
-
getTargets(
{TargetFilter? filter}) → Future< List< TargetInfo> > -
Retrieves a list of available targets.
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. Returns: The list of targets. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
sendMessageToTarget(
String message, {SessionID? sessionId, TargetID? targetId}) → Future< void> -
Sends protocol message over session with given id.
Consider using flat mode instead; see commands attachToTarget, setAutoAttach,
and crbug.com/991325.
sessionId
Identifier of the session. -
setAutoAttach(
bool autoAttach, bool waitForDebuggerOnStart, {bool? flatten, TargetFilter? filter}) → Future< void> -
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.autoAttach
Whether to auto-attach to related targets.waitForDebuggerOnStart
Whether to pause new targets when attaching to them. UseRuntime.runIfWaitingForDebugger
to run paused targets.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.filter
Only targets matching filter will be attached. -
setDiscoverTargets(
bool discover, {TargetFilter? filter}) → Future< void> -
Controls whether to discover available targets and notify via
targetCreated/targetInfoChanged/targetDestroyed
events.discover
Whether to discover available targets.filter
Only targets matching filter will be attached. Ifdiscover
is false,filter
must be omitted or empty. -
setRemoteLocations(
List< RemoteLocation> locations) → Future<void> -
Enables target discovery for the specified locations, when
setDiscoverTargets
was set totrue
.locations
List of remote locations. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited