Target

class Target(cdp: CDP) : Domain

Supports additional targets discovery and allows to attach to them.

Constructors

Link copied to clipboard
constructor(cdp: CDP)

Types

Link copied to clipboard
@Serializable
data class ActivateTargetParameter(val targetId: String)
Link copied to clipboard
@Serializable
data class AttachedToTargetParameter(val sessionId: String, val targetInfo: Target.TargetInfo, val waitingForDebugger: Boolean)

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

Link copied to clipboard
@Serializable
data class AttachToBrowserTargetReturn(val sessionId: String)
Link copied to clipboard
@Serializable
data class AttachToTargetParameter(val targetId: String, val flatten: Boolean? = null)
Link copied to clipboard
@Serializable
data class AttachToTargetReturn(val sessionId: String)
Link copied to clipboard
@Serializable
data class AutoAttachRelatedParameter(val targetId: String, val waitForDebuggerOnStart: Boolean, val filter: List<Double>? = null)
Link copied to clipboard
@Serializable
data class CloseTargetParameter(val targetId: String)
Link copied to clipboard
@Serializable
data class CloseTargetReturn(val success: Boolean)
Link copied to clipboard
@Serializable
data class CreateBrowserContextParameter(val disposeOnDetach: Boolean? = null, val proxyServer: String? = null, val proxyBypassList: String? = null, val originsWithUniversalNetworkAccess: List<String>? = null)
Link copied to clipboard
@Serializable
data class CreateBrowserContextReturn(val browserContextId: String)
Link copied to clipboard
@Serializable
data class CreateTargetParameter(val url: String, val left: Int? = null, val top: Int? = null, val width: Int? = null, val height: Int? = null, val windowState: Target.WindowState? = null, val browserContextId: String? = null, val enableBeginFrameControl: Boolean? = null, val newWindow: Boolean? = null, val background: Boolean? = null, val forTab: Boolean? = null, val hidden: Boolean? = null)
Link copied to clipboard
@Serializable
data class CreateTargetReturn(val targetId: String)
Link copied to clipboard
@Serializable
data class DetachedFromTargetParameter(val sessionId: String, val targetId: String? = null)

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
@Serializable
data class DetachFromTargetParameter(val sessionId: String? = null, val targetId: String? = null)
Link copied to clipboard
@Serializable
data class DisposeBrowserContextParameter(val browserContextId: String)
Link copied to clipboard
@Serializable
data class ExposeDevToolsProtocolParameter(val targetId: String, val bindingName: String? = null, val inheritPermissions: Boolean? = null)
Link copied to clipboard
@Serializable
data class FilterEntry(val exclude: Boolean? = null, val type: String? = null)

A filter used by target query/discovery/auto-attach operations.

Link copied to clipboard
@Serializable
data class GetBrowserContextsReturn(val browserContextIds: List<String>)
Link copied to clipboard
@Serializable
data class GetTargetInfoParameter(val targetId: String? = null)
Link copied to clipboard
@Serializable
data class GetTargetInfoReturn(val targetInfo: Target.TargetInfo)
Link copied to clipboard
@Serializable
data class GetTargetsParameter(val filter: List<Double>? = null)
Link copied to clipboard
@Serializable
data class GetTargetsReturn(val targetInfos: List<Target.TargetInfo>)
Link copied to clipboard
@Serializable
data class ReceivedMessageFromTargetParameter(val sessionId: String, val message: String, val targetId: String? = null)

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

Link copied to clipboard
@Serializable
data class RemoteLocation(val host: String, val port: Int)
Link copied to clipboard
@Serializable
data class SendMessageToTargetParameter(val message: String, val sessionId: String? = null, val targetId: String? = null)
Link copied to clipboard
@Serializable
data class SetAutoAttachParameter(val autoAttach: Boolean, val waitForDebuggerOnStart: Boolean, val flatten: Boolean? = null, val filter: List<Double>? = null)
Link copied to clipboard
@Serializable
data class SetDiscoverTargetsParameter(val discover: Boolean, val filter: List<Double>? = null)
Link copied to clipboard
@Serializable
data class SetRemoteLocationsParameter(val locations: List<Target.RemoteLocation>)
Link copied to clipboard
@Serializable
data class TargetCrashedParameter(val targetId: String, val status: String, val errorCode: Int)

Issued when a target has crashed.

Link copied to clipboard
@Serializable
data class TargetCreatedParameter(val targetInfo: Target.TargetInfo)

Issued when a possible inspection target is created.

Link copied to clipboard
@Serializable
data class TargetDestroyedParameter(val targetId: String)

Issued when a target is destroyed.

Link copied to clipboard
@Serializable
data class TargetInfo(val targetId: String, val type: String, val title: String, val url: String, val attached: Boolean, val openerId: String? = null, val canAccessOpener: Boolean, val openerFrameId: String? = null, val browserContextId: String? = null, val subtype: String? = null)
Link copied to clipboard
@Serializable
data class TargetInfoChangedParameter(val targetInfo: Target.TargetInfo)

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

Link copied to clipboard
@Serializable
enum WindowState : Enum<Target.WindowState>

The state of the target window.

Properties

Link copied to clipboard

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

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

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

Link copied to clipboard

Issued when a target has crashed.

Link copied to clipboard

Issued when a possible inspection target is created.

Link copied to clipboard

Issued when a target is destroyed.

Link copied to clipboard

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

Functions

Link copied to clipboard
suspend fun activateTarget(targetId: String)
suspend fun activateTarget(args: Target.ActivateTargetParameter, mode: CommandMode = CommandMode.DEFAULT)

Activates (focuses) the target.

Link copied to clipboard
suspend fun attachToBrowserTarget(mode: CommandMode = CommandMode.DEFAULT): Target.AttachToBrowserTargetReturn

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

Link copied to clipboard
suspend fun attachToTarget(targetId: String, flatten: Boolean? = null): Target.AttachToTargetReturn

Attaches to the target with given id.

Link copied to clipboard
suspend fun autoAttachRelated(args: Target.AutoAttachRelatedParameter, mode: CommandMode = CommandMode.DEFAULT)
suspend fun autoAttachRelated(targetId: String, waitForDebuggerOnStart: Boolean, filter: List<Double>? = null)

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(args: Target.CloseTargetParameter, mode: CommandMode = CommandMode.DEFAULT): Target.CloseTargetReturn

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

Link copied to clipboard
suspend fun createBrowserContext(disposeOnDetach: Boolean? = null, proxyServer: String? = null, proxyBypassList: String? = null, originsWithUniversalNetworkAccess: List<String>? = null): Target.CreateBrowserContextReturn

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

Link copied to clipboard
suspend fun createTarget(args: Target.CreateTargetParameter, mode: CommandMode = CommandMode.DEFAULT): Target.CreateTargetReturn
suspend fun createTarget(url: String, left: Int? = null, top: Int? = null, width: Int? = null, height: Int? = null, windowState: Target.WindowState? = null, browserContextId: String? = null, enableBeginFrameControl: Boolean? = null, newWindow: Boolean? = null, background: Boolean? = null, forTab: Boolean? = null, hidden: Boolean? = null): Target.CreateTargetReturn

Creates a new page.

Link copied to clipboard
suspend fun detachFromTarget(args: Target.DetachFromTargetParameter, mode: CommandMode = CommandMode.DEFAULT)
suspend fun detachFromTarget(sessionId: String? = null, targetId: String? = null)

Detaches session with given id.

Link copied to clipboard
suspend fun disposeBrowserContext(browserContextId: String)
suspend fun disposeBrowserContext(args: Target.DisposeBrowserContextParameter, mode: CommandMode = CommandMode.DEFAULT)

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

Link copied to clipboard
suspend fun exposeDevToolsProtocol(args: Target.ExposeDevToolsProtocolParameter, mode: CommandMode = CommandMode.DEFAULT)
suspend fun exposeDevToolsProtocol(targetId: String, bindingName: String? = null, inheritPermissions: Boolean? = null)

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

Link copied to clipboard
suspend fun getBrowserContexts(mode: CommandMode = CommandMode.DEFAULT): Target.GetBrowserContextsReturn

Returns all browser contexts created with Target.createBrowserContext method.

Link copied to clipboard
suspend fun getTargetInfo(targetId: String? = null): Target.GetTargetInfoReturn

Returns information about a target.

Link copied to clipboard
suspend fun getTargets(filter: List<Double>? = null): Target.GetTargetsReturn
suspend fun getTargets(args: Target.GetTargetsParameter, mode: CommandMode = CommandMode.DEFAULT): Target.GetTargetsReturn

Retrieves a list of available targets.

Link copied to clipboard
suspend fun sendMessageToTarget(args: Target.SendMessageToTargetParameter, mode: CommandMode = CommandMode.DEFAULT)
suspend fun sendMessageToTarget(message: String, sessionId: String? = null, targetId: String? = null)

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
suspend fun setAutoAttach(args: Target.SetAutoAttachParameter, mode: CommandMode = CommandMode.DEFAULT)
suspend fun setAutoAttach(autoAttach: Boolean, waitForDebuggerOnStart: Boolean, flatten: Boolean? = null, filter: List<Double>? = null)

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 autoAttachRelated from 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.

Link copied to clipboard
suspend fun setDiscoverTargets(args: Target.SetDiscoverTargetsParameter, mode: CommandMode = CommandMode.DEFAULT)
suspend fun setDiscoverTargets(discover: Boolean, filter: List<Double>? = null)

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

Link copied to clipboard
suspend fun setRemoteLocations(args: Target.SetRemoteLocationsParameter, mode: CommandMode = CommandMode.DEFAULT)

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