TargetDomain

Supports additional targets discovery and allows to attach to them.

Official doc

Functions

Link copied to clipboard

Activates (focuses) the target.

Link copied to clipboard

When collected, this flow enables target discovery and aggregates single-target events to provide updates to a complete map of targets by ID.

Link copied to clipboard
Link copied to clipboard

Issued when attached to target because of auto-attach or attachToTarget command.

Link copied to clipboard

Attaches to the browser target, only uses flat sessionId mode.

Link copied to clipboard
inline suspend fun attachToTarget(targetId: TargetID, optionalArgs: AttachToTargetRequest.Builder.() -> Unit = {}): AttachToTargetResponse

Attaches to the target with given id.

Link copied to clipboard
inline suspend fun autoAttachRelated(targetId: TargetID, waitForDebuggerOnStart: Boolean, optionalArgs: AutoAttachRelatedRequest.Builder.() -> Unit = {}): AutoAttachRelatedResponse

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.

Link copied to clipboard
suspend fun closeTarget(targetId: TargetID): CloseTargetResponse

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

Link copied to clipboard

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

Link copied to clipboard
inline suspend fun createTarget(url: String, optionalArgs: CreateTargetRequest.Builder.() -> Unit = {}): CreateTargetResponse

Creates a new page.

Link copied to clipboard

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.

Link copied to clipboard

Detaches session with given id.

Link copied to clipboard

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

Link copied to clipboard
fun events(): Flow<TargetEvent>

Subscribes to all events related to this domain.

Link copied to clipboard

Inject object to the target's main frame that provides a communication channel with browser target.

Link copied to clipboard

Returns all browser contexts created with Target.createBrowserContext method.

Link copied to clipboard

Returns information about a target.

Link copied to clipboard
inline suspend fun getTargets(optionalArgs: GetTargetsRequest.Builder.() -> Unit = {}): GetTargetsResponse

Retrieves a list of available targets.

Link copied to clipboard

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

Link copied to clipboard

Sends protocol message over session with given id. Consider using flat mode instead; see commands attachToTarget, setAutoAttach, and crbug.com/991325.

Link copied to clipboard
inline suspend fun setAutoAttach(autoAttach: Boolean, waitForDebuggerOnStart: Boolean, optionalArgs: SetAutoAttachRequest.Builder.() -> Unit = {}): SetAutoAttachResponse

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.

Link copied to clipboard

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

Link copied to clipboard

Enables target discovery for the specified locations, when setDiscoverTargets was set to true.

Link copied to clipboard
Link copied to clipboard

Issued when a target has crashed.

Link copied to clipboard
Link copied to clipboard

Issued when a possible inspection target is created.

Link copied to clipboard
Link copied to clipboard

Issued when a target is destroyed.

Link copied to clipboard
Link copied to clipboard

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