chrome-devtools-kotlin / org.hildan.chrome.devtools.protocol / ChromeDPClient

ChromeDPClient

class ChromeDPClient

A Chrome Devtools Protocol client.

It provides access to the basic HTTP endpoints exposed by the Chrome browser, as well as web socket connections to the browser and its targets to make use of the full Chrome Devtools Protocol API.

Constructors

<init>

A Chrome Devtools Protocol client.

ChromeDPClient(remoteDebugUrl: String = "http://localhost:9222", httpClient: HttpClient = DEFAULT_HTTP_CLIENT, webSocketClient: WebSocketClient = DEFAULT_WEBSOCKET_CLIENT)

Functions

activateTab

Brings a page into the foreground (activate a tab).

suspend fun activateTab(targetId: String): String

closeAllTargets

Closes all targets.

suspend fun closeAllTargets(): Unit

closeTab

Closes the target page identified by targetId.

suspend fun closeTab(targetId: String): String

newTab

Opens a new tab. Responds with the websocket target data for the new tab.

suspend fun newTab(url: String = "about:blank"): ChromeDPTarget

protocolJson

The current devtools protocol definition, as a JSON string.

suspend fun protocolJson(): String

targets

A list of all available websocket targets (e.g. browser tabs).

suspend fun targets(): List<ChromeDPTarget>

version

Browser version metadata.

suspend fun version(): ChromeVersion

webSocket

Opens a web socket connection to interact with the root (browser) session.

suspend fun webSocket(): ChromeBrowserSession