This module provides a direct mapping of CDP events and commands for v1.3 (stable) of the Target Domain.
The Target Domain supports additional targets discovery and allows to attach to them.
Types
Target {.pure.} = enum receivedMessageFromTarget = "Target.receivedMessageFromTarget", targetCreated = "Target.targetCreated", targetDestroyed = "Target.targetDestroyed", targetCrashed = "Target.targetCrashed", targetInfoChanged = "Target.targetInfoChanged"
- Target Domain events
Procs
proc activateTarget(browser: Browser; targetId: string): owned(Future[void]) {. ...stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
activates (focuses) the target.
proc attachToTarget(browser: Browser; targetId: string): Future[JsonNode] {. ...stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
attaches to the target with the given targetId.
flatten parameter is forced true to simplify the API (and will be default in future versions of CDP).
proc closeTarget(browser: Browser; targetId: string): owned(Future[void]) {. ...stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Closes the target. If the target is a page that gets closed too.
Note: the return object is deprecated, so we return a Future[void] instead.
proc createBrowserContext(browser: Browser): Future[JsonNode] {. ...stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc createBrowserContext(browser: Browser; params: JsonNode): Future[JsonNode] {. ...stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Creates a new browser context. Similar to an incognito profile but you can have more than one.
proc createTarget(browser: Browser; url: string = ""): Future[JsonNode] {. ...stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc createTarget(browser: Browser; url: string = ""; params: JsonNode): Future[ JsonNode] {....stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
creates a new page. Passing "" to url parameter will create a blank page (about:blank).
proc detachFromTarget(browser: Browser; sessionId: string): owned( Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
detaches session with given id.
proc disposeBrowserContext(browser: Browser; browserContextId: string): owned( Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Deletes a browser context. All the belonging pages will be closed without calling their beforeunload hooks.
proc getBrowserContexts(browser: Browser): Future[JsonNode] {....stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
returns all browser contexts created with Target.createBrowserContext.
proc getTargets(browser: Browser): Future[JsonNode] {....stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc getTargets(browser: Browser; params: JsonNode): Future[JsonNode] {. ...stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
retrieves a list of available targets.
proc setAutoAttach(browser: Browser; autoAttach, waitForDebuggerOnStart: bool): owned( Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc setAutoAttach(browser: Browser; autoAttach, waitForDebuggerOnStart: bool; params: JsonNode): owned(Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
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. flatten parameter is forced true to simplify the API (and will be default in future versions of CDP).
proc setDiscoverTargets(browser: Browser; discover: bool): owned( Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc setDiscoverTargets(browser: Browser; discover: bool; params: JsonNode): owned( Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Controls whether to discover available targets and notify via Target.targetCreated/Target.targetDestroyed/ Target.targetInfoChanged events.