chrome-reactive-kotlin is a low level Chrome DevTools Protocol client written in Kotlin and leveraging RxJava3 for easy composability.
Library exposes all protocol domains in a single, cohesive and highly composable API. It supports both headless and standalone Chrome versions and supports creating isolated environments via BrowserContext from Target domain and flatted sessions mode (see: http://crbug.com/991325).
For debugging purposes you can use my other project: chrome-protocol-proxy.
Please note that most up-to-date protocol is used at the moment.
Documentation can be found on https://wendigo.github.io/chrome-reactive-kotlin/.
build.gradle
:
implementation 'pl.wendigo:chrome-reactive-kotlin:0.7.1'
build.gradle.kts
:
implementation("pl.wendigo:chrome-reactive-kotlin:0.7.1")
pom.xml
:
<dependency> <groupId>pl.wendigo</groupId> <artifactId>chrome-reactive-kotlin</artifactId> <version>0.7.1</version> </dependency>
Run headless chrome:
docker container run -d -p 9222:9222 eu.gcr.io/zenika-hub/alpine-chrome:89 --no-sandbox --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 about:blank
And now execute:
import pl.wendigo.chrome.api.page.NavigateRequest fun main() { val chrome = Browser.builder() .withAddress("127.0.0.1:9222") .build() chrome.use { browser -> browser.target("about:blank").use { target -> await { target.Page.enable() } await { target.Page.navigate(NavigateRequest(url = "https://github.com/wendigo/chrome-reactive-kotlin")).flatMap { (frameId) -> target.Page.frameStoppedLoading().filter { it.frameId == frameId }.take(1).singleOrError() } } } } }