TargetApi class Null safety

Supports additional targets discovery and allows to attach to them.

Constructors

TargetApi(Client _client)

Properties

hashCode int
The hash code for this object.
read-onlyinherited
onAttachedToTarget Stream<AttachedToTargetEvent>
Issued when attached to target because of auto-attach or attachToTarget command.
read-only
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.
read-only
onReceivedMessageFromTarget Stream<ReceivedMessageFromTargetEvent>
Notifies about a new protocol message received from the session (as reported in attachedToTarget event).
read-only
onTargetCrashed Stream<TargetCrashedEvent>
Issued when a target has crashed.
read-only
onTargetCreated Stream<TargetInfo>
Issued when a possible inspection target is created.
read-only
onTargetDestroyed Stream<TargetID>
Issued when a target is destroyed.
read-only
onTargetInfoChanged Stream<TargetInfo>
Issued when some information about a target has changed. This only happens between targetCreated and targetDestroyed.
read-only
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited

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 previous setAutoAttach and is also cancelled by subsequent setAutoAttach. Only available at the Browser target. waitForDebuggerOnStart Whether to pause new targets when attaching to them. Use Runtime.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-server proxyBypassList Proxy bypass list, similar to the one passed to --proxy-bypass-list originsWithUniversalNetworkAccess 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}) 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). 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 non-existent 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.
@Deprecated('This command is deprecated')
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. Use Runtime.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. If discover 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 to true. locations List of remote locations.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited