This module provides the basic types and procedures for interacting with the Chrome DevTools Protocol (CDP).
Types
Browser = ref object chrome*: Process userDataDir*: tuple[dir: string, isTempDir: bool] ws*: WebSocket requestId*: RequestId responseTable*: ResponseTable globalEventTable*: GlobalEventTable sessionEventTable*: SessionEventTable
- Represents a Browser instance. Fields are read-only and should not be used directly.
CDPError = object of CatchableError
EventCallback = proc (data: JsonNode) {.async.}
GlobalEventTable = Table[ProtocolEvent, EventCallback]
ProtocolEvent = string
RequestId = int
ResponseTable = Table[RequestId, Future[JsonNode]]
SessionEventTable = Table[SessionId, Table[ProtocolEvent, EventCallback]]
SessionId = string
Procs
proc sendCommand(browser: Browser; mthd: string): Future[JsonNode] {. ...stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
This is a generic procedure for sending a command to the CDP endpoint. All wrapped CDP v1.3 methods/commands use a version of this procedure.
If you need to send a command that is not covered by the v1.3 of CDP, like those from experimental Domains, you can use this procedure to create a new wrapper or send the command directly.
proc sendCommand(browser: Browser; mthd: string; params: JsonNode): Future[ JsonNode] {....stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
- Version of sendCommand that sends a command with parameters (for the Browser object).
proc sendCommand(tab: Tab; mthd: string): Future[JsonNode] {....stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
- Version of sendCommand that sends a command without parameters (for the Tab object).
proc sendCommand(tab: Tab; mthd: string; params: JsonNode): Future[JsonNode] {. ...stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
- Version of sendCommand that sends a command with parameters (for the Tab object).