Methods

Chrome DevTools

Target.activateTarget #

Activates (focuses) the target.

Parameters

targetId

Chrome DevTools

Target.attachToTarget #

Attaches to the target with given id.

Parameters

targetId
flatten
Optional
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.


Chrome DevTools

Target.closeTarget #

Closes the target. If the target is a page that gets closed too.

Parameters

targetId

Return object

success
boolean

Always set to true. If an error occurs, the response indicates protocol error.

Deprecated

Chrome DevTools

Target.createBrowserContext #

Creates a new empty BrowserContext. Similar to an incognito profile but you can have more than one.

Parameters

disposeOnDetach
Optional
boolean

If specified, disposes this context when debugging session disconnects.

Experimental
proxyServer
Optional
string

Proxy server, similar to the one passed to --proxy-server

Experimental
proxyBypassList
Optional
string

Proxy bypass list, similar to the one passed to --proxy-bypass-list

Experimental
originsWithUniversalNetworkAccess
Optional
array[ string ]

An optional list of origins to grant unlimited cross-origin access to. Parts of the URL other than those constituting origin are ignored.

Experimental

Return object

browserContextId
Browser.BrowserContextID

The id of the context created.


Chrome DevTools

Target.createTarget #

Creates a new page.

Parameters

url
string

The initial URL the page will be navigated to. An empty string indicates about:blank.

width
Optional
integer

Frame width in DIP (headless chrome only).

height
Optional
integer

Frame height in DIP (headless chrome only).

browserContextId
Optional
Browser.BrowserContextID

The browser context to create the page in.

Experimental
enableBeginFrameControl
Optional
boolean

Whether BeginFrames for this target will be controlled via DevTools (headless chrome only, not supported on MacOS yet, false by default).

Experimental
newWindow
Optional
boolean

Whether to create a new Window or Tab (chrome-only, false by default).

background
Optional
boolean

Whether to create the target in background or foreground (chrome-only, false by default).

forTab
Optional
boolean

Whether to create the target of type "tab".

Experimental

Return object

targetId
TargetID

The id of the page opened.


Chrome DevTools

Target.detachFromTarget #

Detaches session with given id.

Parameters

sessionId
Optional
SessionID

Session to detach.

targetId
Optional
TargetID

Deprecated.

Deprecated

Chrome DevTools

Target.disposeBrowserContext #

Deletes a BrowserContext. All the belonging pages will be closed without calling their beforeunload hooks.

Parameters

browserContextId

Chrome DevTools

Target.getBrowserContexts #

Returns all browser contexts created with Target.createBrowserContext method.

Return object

browserContextIds
array[ Browser.BrowserContextID ]

An array of browser context ids.


Chrome DevTools

Target.getTargets #

Retrieves a list of available targets.

Parameters

filter
Optional
TargetFilter

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.

Experimental

Return object

targetInfos
array[ TargetInfo ]

The list of targets.


Chrome DevTools

Target.setAutoAttach #

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

autoAttach
boolean

Whether to auto-attach to related targets.

waitForDebuggerOnStart
boolean

Whether to pause new targets when attaching to them. Use Runtime.runIfWaitingForDebugger to run paused targets.

flatten
Optional
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.

Experimental
filter
Optional
TargetFilter

Only targets matching filter will be attached.

Experimental

Chrome DevTools

Target.setDiscoverTargets #

Controls whether to discover available targets and notify via targetCreated/targetInfoChanged/targetDestroyed events.

Parameters

discover
boolean

Whether to discover available targets.

filter
Optional
TargetFilter

Only targets matching filter will be attached. If discover is false, filter must be omitted or empty.

Experimental

Events

Chrome DevTools

Target.receivedMessageFromTarget #

Notifies about a new protocol message received from the session (as reported in attachedToTarget event).

Parameters

sessionId
SessionID

Identifier of a session which sends a message.

message
string
targetId
Optional
TargetID

Deprecated.

Deprecated

Chrome DevTools

Target.targetCrashed #

Issued when a target has crashed.

Parameters

targetId
status
string

Termination status type.

errorCode
integer

Termination error code.


Chrome DevTools

Target.targetCreated #

Issued when a possible inspection target is created.

Parameters

targetInfo

Chrome DevTools

Target.targetDestroyed #

Issued when a target is destroyed.

Parameters

targetId

Chrome DevTools

Target.targetInfoChanged #

Issued when some information about a target has changed. This only happens between targetCreated and targetDestroyed.

Parameters

targetInfo

Types

Chrome DevTools

Target.SessionID #

Unique identifier of attached debugging session.

Type: string


Chrome DevTools

Target.TargetID #

Type: string


Chrome DevTools

Target.TargetInfo #

Type: object

Properties

targetId
type
string

List of types: https://source.chromium.org/chromium/chromium/src/+/main:content/browser/devtools/devtools_agent_host_impl.cc?ss=chromium&q=f:devtools%20-f:out%20%22::kTypeTab%5B%5D%22

title
string
url
string
attached
boolean

Whether the target has an attached client.

openerId
Optional
TargetID

Opener target Id

canAccessOpener
boolean

Whether the target has access to the originating window.

Experimental
openerFrameId
Optional
Page.FrameId

Frame id of originating window (is only set if target has an opener).

Experimental
browserContextId
Optional
subtype
Optional
string

Provides additional details for specific target types. For example, for the type of "page", this may be set to "portal" or "prerender".

Experimental