chrome-devtools-kotlin / org.hildan.chrome.devtools.domains.target / TargetDomain

TargetDomain

class TargetDomain

Supports additional targets discovery and allows to attach to them.

Functions

activateTarget

Activates (focuses) the target.

suspend fun activateTarget(input: ActivateTargetRequest): Unit

attachedToTarget

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

fun attachedToTarget(): Flow<AttachedToTargetEvent>

attachToBrowserTarget

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

suspend fun attachToBrowserTarget(): AttachToBrowserTargetResponse

attachToTarget

Attaches to the target with given id.

suspend fun attachToTarget(input: AttachToTargetRequest): AttachToTargetResponse

closeTarget

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

suspend fun closeTarget(input: CloseTargetRequest): CloseTargetResponse

createBrowserContext

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

suspend fun createBrowserContext(input: CreateBrowserContextRequest): CreateBrowserContextResponse

createTarget

Creates a new page.

suspend fun createTarget(input: CreateTargetRequest): CreateTargetResponse

detachedFromTarget

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.

fun detachedFromTarget(): Flow<DetachedFromTargetEvent>

detachFromTarget

Detaches session with given id.

suspend fun detachFromTarget(input: DetachFromTargetRequest): Unit

disposeBrowserContext

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

suspend fun disposeBrowserContext(input: DisposeBrowserContextRequest): Unit

events

Subscribes to all events related to this domain.

fun events(): Flow<TargetEvent>

exposeDevToolsProtocol

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

suspend fun exposeDevToolsProtocol(input: ExposeDevToolsProtocolRequest): Unit

getBrowserContexts

Returns all browser contexts created with Target.createBrowserContext method.

suspend fun getBrowserContexts(): GetBrowserContextsResponse

getTargetInfo

Returns information about a target.

suspend fun getTargetInfo(input: GetTargetInfoRequest): GetTargetInfoResponse

getTargets

Retrieves a list of available targets.

suspend fun getTargets(): GetTargetsResponse

receivedMessageFromTarget

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

fun receivedMessageFromTarget(): Flow<ReceivedMessageFromTargetEvent>

sendMessageToTarget

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

suspend fun sendMessageToTarget(input: SendMessageToTargetRequest): Unit

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.

suspend fun setAutoAttach(input: SetAutoAttachRequest): Unit

setDiscoverTargets

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

suspend fun setDiscoverTargets(input: SetDiscoverTargetsRequest): Unit

setRemoteLocations

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

suspend fun setRemoteLocations(input: SetRemoteLocationsRequest): Unit

targetCrashed

Issued when a target has crashed.

fun targetCrashed(): Flow<TargetCrashedEvent>

targetCreated

Issued when a possible inspection target is created.

fun targetCreated(): Flow<TargetCreatedEvent>

targetDestroyed

Issued when a target is destroyed.

fun targetDestroyed(): Flow<TargetDestroyedEvent>

targetInfoChanged

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

fun targetInfoChanged(): Flow<TargetInfoChangedEvent>