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
attachToTargetcommand.no setter -
onDetachedFromTarget
→ Stream<
DetachedFromTargetEvent> -
Issued when detached from target for any reason (including
detachFromTargetcommand). 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
attachedToTargetevent).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
targetCreatedandtargetDestroyed.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.
flattenEnables "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 previoussetAutoAttachand is also cancelled by subsequentsetAutoAttach. Only available at the Browser target.waitForDebuggerOnStartWhether to pause new targets when attaching to them. UseRuntime.runIfWaitingForDebuggerto run paused targets.filterOnly 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.
disposeOnDetachIf specified, disposes this context when debugging session disconnects.proxyServerProxy server, similar to the one passed to --proxy-serverproxyBypassListProxy bypass list, similar to the one passed to --proxy-bypass-listoriginsWithUniversalNetworkAccessAn 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? left, int? top, int? width, int? height, WindowState? windowState, BrowserContextID? browserContextId, bool? enableBeginFrameControl, bool? newWindow, bool? background, bool? forTab, }) → Future< TargetID> -
Creates a new page.
urlThe initial URL the page will be navigated to. An empty string indicates about:blank.leftFrame left origin in DIP (requires newWindow to be true or headless shell).topFrame top origin in DIP (requires newWindow to be true or headless shell).widthFrame width in DIP (requires newWindow to be true or headless shell).heightFrame height in DIP (requires newWindow to be true or headless shell).windowStateFrame window state (requires newWindow to be true or headless shell). Default is normal.browserContextIdThe browser context to create the page in.enableBeginFrameControlWhether BeginFrames for this target will be controlled via DevTools (headless shell only, not supported on MacOS yet, false by default).newWindowWhether to create a new Window or Tab (false by default, not supported by headless shell).backgroundWhether to create the target in background or foreground (false by default, not supported by headless shell).forTabWhether to create the target of type "tab".hiddenWhether to create a hidden target. The hidden target is observable via protocol, but not present in the tab UI strip. Cannot be created withforTab: true,newWindow: trueorbackground: false. The life-time of the tab is limited to the life-time of the session. Returns: The id of the page opened. -
detachFromTarget(
{SessionID? sessionId, TargetID? targetId}) → Future< void> -
Detaches session with given id.
sessionIdSession 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, bool? inheritPermissions}) → 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.createBrowserContextmethod. 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.
filterOnly 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.
sessionIdIdentifier 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 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
autoAttachRelatedfrom 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.autoAttachWhether to auto-attach to related targets.waitForDebuggerOnStartWhether to pause new targets when attaching to them. UseRuntime.runIfWaitingForDebuggerto run paused targets.flattenEnables "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.filterOnly targets matching filter will be attached. -
setDiscoverTargets(
bool discover, {TargetFilter? filter}) → Future< void> -
Controls whether to discover available targets and notify via
targetCreated/targetInfoChanged/targetDestroyedevents.discoverWhether to discover available targets.filterOnly targets matching filter will be attached. Ifdiscoveris false,filtermust be omitted or empty. -
setRemoteLocations(
List< RemoteLocation> locations) → Future<void> -
Enables target discovery for the specified locations, when
setDiscoverTargetswas set totrue.locationsList of remote locations. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited