Chrome DevTools Protocol
Target Domain
Supports additional targets discovery and allows to attach to them.
Methods
Events
Types
Methods
Target.attachToTarget#
Attaches to the target with given id.
parameters
- targetId
- TargetID
- flatten
- boolean
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.
Return Object
- sessionId
- SessionID
Id assigned to the session.
Target.closeTarget#
Closes the target. If the target is a page that gets closed too.
parameters
- targetId
- TargetID
Return Object
- success
- booleanDeprecated
Always set to true. If an error occurs, the response indicates protocol error.
Target.createBrowserContext#
Creates a new empty BrowserContext. Similar to an incognito profile but you can have more thanone.
parameters
- disposeOnDetach
- booleanExperimental
If specified, disposes this context when debugging session disconnects.
- proxyServer
- stringExperimental
Proxy server, similar to the one passed to --proxy-server
- proxyBypassList
- stringExperimental
Proxy bypass list, similar to the one passed to --proxy-bypass-list
- originsWithUniversalNetworkAccess
- array[string ]Experimental
An optional list of origins to grant unlimited cross-origin access to.Parts of the URL other than those constituting origin are ignored.
Return Object
- browserContextId
- Browser.BrowserContextID
The id of the context created.
Target.createTarget#
Creates a new page.
parameters
- url
- string
The initial URL the page will be navigated to. An empty string indicates about:blank.
- left
- integerExperimental
Frame left origin in DIP (requires newWindow to be true or headless shell).
- top
- integerExperimental
Frame top origin in DIP (requires newWindow to be true or headless shell).
- width
- integer
Frame width in DIP (requires newWindow to be true or headless shell).
- height
- integer
Frame height in DIP (requires newWindow to be true or headless shell).
- windowState
- WindowState
Frame window state (requires newWindow to be true or headless shell).Default is normal.
- browserContextId
- Browser.BrowserContextIDExperimental
The browser context to create the page in.
- enableBeginFrameControl
- booleanExperimental
Whether BeginFrames for this target will be controlled via DevTools (headless shell only,not supported on MacOS yet, false by default).
- newWindow
- boolean
Whether to create a new Window or Tab (false by default, not supported by headless shell).
- background
- boolean
Whether to create the target in background or foreground (false by default, not supportedby headless shell).
- forTab
- booleanExperimental
Whether to create the target of type "tab".
- hidden
- booleanExperimental
Whether to create a hidden target. The hidden target is observable via protocol, but notpresent in the tab UI strip. Cannot be created with
forTab: true,newWindow: trueorbackground: false. The life-time of the tab is limited to the life-time of the session.
Return Object
- targetId
- TargetID
The id of the page opened.
Target.disposeBrowserContext#
Deletes a BrowserContext. All the belonging pages will be closed without calling theirbeforeunload hooks.
parameters
- browserContextId
- Browser.BrowserContextID
Target.getBrowserContexts#
Returns all browser contexts created withTarget.createBrowserContext method.
Return Object
- browserContextIds
- array[Browser.BrowserContextID ]
An array of browser context ids.
Target.getTargets#
Retrieves a list of available targets.
parameters
- filter
- TargetFilterExperimental
Only targets matching filter will be reported. If filter is not specifiedand target discovery is currently enabled, a filter used for target discoveryis used for consistency.
Return Object
- targetInfos
- array[TargetInfo ]
The list of targets.
Target.setAutoAttach#
Controls whether to automatically attach to new targets which are consideredto 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 byautoAttachRelated from the list of targets to watchfor creation of related targets.You might want to call this recursively for auto-attached targets to attachto all available targets.
parameters
- autoAttach
- boolean
Whether to auto-attach to related targets.
- waitForDebuggerOnStart
- boolean
Whether to pause new targets when attaching to them. Use
Runtime.runIfWaitingForDebuggerto run paused targets. - flatten
- booleanExperimental
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
- TargetFilterExperimental
Only targets matching filter will be attached.
Target.setDiscoverTargets#
Controls whether to discover available targets and notify viatargetCreated/targetInfoChanged/targetDestroyed events.
parameters
- discover
- boolean
Whether to discover available targets.
- filter
- TargetFilterExperimental
Only targets matching filter will be attached. If
discoveris false,filtermust be omitted or empty.
Target.sendMessageToTargetDeprecated#
Sends protocol message over session with given id.Consider using flat mode instead; see commands attachToTarget, setAutoAttach,and crbug.com/991325.
parameters
Target.attachToBrowserTargetExperimental#
Attaches to the browser target, only uses flat sessionId mode.
Return Object
- sessionId
- SessionID
Id assigned to the session.
Target.autoAttachRelatedExperimental#
Adds the specified target to the list of targets that will be monitored for any related targetcreation (such as child frames, child workers and new versions of service worker) and reportedthroughattachedToTarget. 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.
parameters
- targetId
- TargetID
- waitForDebuggerOnStart
- boolean
Whether to pause new targets when attaching to them. Use
Runtime.runIfWaitingForDebuggerto run paused targets. - filter
- TargetFilterExperimental
Only targets matching filter will be attached.
Target.exposeDevToolsProtocolExperimental#
Inject object to the target's main frame that provides a communicationchannel with browser target.
Injected object will be available aswindow[bindingName].
The object has the following 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
- targetId
- TargetID
- bindingName
- string
Binding name, 'cdp' if not specified.
- inheritPermissions
- boolean
If true, inherits the current root session's permissions (default: false).
Target.getDevToolsTargetExperimental#
Gets the targetId of the DevTools page target opened for the given target(if any).
parameters
- targetId
- TargetID
Page or tab target ID.
Return Object
- targetId
- TargetID
The targetId of DevTools page target if exists.
Target.getTargetInfoExperimental#
Returns information about a target.
parameters
- targetId
- TargetID
Return Object
- targetInfo
- TargetInfo
Target.openDevToolsExperimental#
Opens a DevTools window for the target.
parameters
- targetId
- TargetID
This can be the page or tab target ID.
- panelId
- string
The id of the panel we want DevTools to open initially. Currentlysupported panels are elements, console, network, sources, resourcesand performance.
Return Object
- targetId
- TargetID
The targetId of DevTools page target.
Target.setRemoteLocationsExperimental#
Enables target discovery for the specified locations, whensetDiscoverTargets was set totrue.
parameters
- locations
- array[RemoteLocation ]
List of remote locations.
Events
Target.receivedMessageFromTarget#
Notifies about a new protocol message received from the session (as reported inattachedToTarget event).
parameters
Target.targetCrashed#
Issued when a target has crashed.
parameters
- targetId
- TargetID
- status
- string
Termination status type.
- errorCode
- integer
Termination error code.
Target.targetCreated#
Issued when a possible inspection target is created.
parameters
- targetInfo
- TargetInfo
Target.targetInfoChanged#
Issued when some information about a target has changed. This only happens betweentargetCreated andtargetDestroyed.
parameters
- targetInfo
- TargetInfo
Target.attachedToTargetExperimental#
Issued when attached to target because of auto-attach orattachToTarget command.
parameters
- sessionId
- SessionID
Identifier assigned to the session used to send/receive messages.
- targetInfo
- TargetInfo
- waitingForDebugger
- boolean
Target.detachedFromTargetExperimental#
Issued when detached from target for any reason (includingdetachFromTarget command). Can beissued multiple times per target if multiple sessions have been attached to it.
parameters
Types
Target.TargetID#
Type:string
Target.TargetInfo#
Type:object
properties
- targetId
- TargetID
- type
- string
- title
- string
- url
- string
- attached
- boolean
Whether the target has an attached client.
- openerId
- TargetID
Opener target Id
- canAccessOpener
- booleanExperimental
Whether the target has access to the originating window.
- openerFrameId
- Page.FrameIdExperimental
Frame id of originating window (is only set if target has an opener).
- parentFrameId
- Page.FrameIdExperimental
Id of the parent frame, only present for the "iframe" targets.
- browserContextId
- Browser.BrowserContextIDExperimental
- subtype
- stringExperimental
Provides additional details for specific target types. For example, forthe type of "page", this may be set to "prerender".
Target.FilterEntryExperimental#
A filter used by target query/discovery/auto-attach operations.
Type:object
properties
- exclude
- boolean
If set, causes exclusion of matching targets from the list.
- type
- string
If not present, matches any type.
Target.TargetFilterExperimental#
The entries in TargetFilter are matched sequentially against targets andthe first entry that matches determines if the target is included or not,depending on the value ofexclude 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 butbrowser andtab).
Type:array
Target.WindowStateExperimental#
The state of the target window.
normal,minimized,maximized,fullscreenType:string