ChromeDP

This is the entry point of the interactions with a Chrome browser.

First, make sure a Chrome browser is already running externally. You should then have either an HTTP or a web socket URL to connect to the debugger. Use connect to connect to the remote debugger and get a BrowserSession. Check out the KDoc of these declarations for more info.

If you instead want to use the HTTP JSON endpoints to query metadata about the browser, use the httpApi method. Note that it is not recommended to use the returned ChromeDPHttpApi to manage targets, because not all headless browsers support these endpoints (and they are superseded by the web socket API).

See also

Functions

Link copied to clipboard
suspend fun connect(wsOrHttpUrl: String, sessionContext: CoroutineContext = EmptyCoroutineContext, configureClient: HttpClientConfig<*>.() -> Unit? = null): BrowserSession

Connects to the Chrome debugger at the given wsOrHttpUrl (either web socket or HTTP), opening a BrowserSession.

Link copied to clipboard
fun httpApi(httpUrl: String, overrideHostHeader: Boolean = false, httpClient: HttpClient = defaultHttpClient): ChromeDPHttpApi
fun httpApi(httpUrl: String, overrideHostHeader: Boolean = false, configureClient: HttpClientConfig<*>.() -> Unit): ChromeDPHttpApi

Creates a client that uses Chrome's JSON HTTP endpoints to query metadata about the browser or the protocol, and to list, create and close targets (e.g. tabs).