Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wendigo/chrome-reactive-kotlin
Headless Chrome DevTools Protocol Client (RxJava3 + Kotlin)
https://github.com/wendigo/chrome-reactive-kotlin
chrome chrome-browser chrome-devtools-protocol debugging-tool headless-chrome kotlin protocol remote remote-control remote-execution rxjava rxjava2
Last synced: 3 months ago
JSON representation
Headless Chrome DevTools Protocol Client (RxJava3 + Kotlin)
- Host: GitHub
- URL: https://github.com/wendigo/chrome-reactive-kotlin
- Owner: wendigo
- License: apache-2.0
- Created: 2017-03-03T12:13:21.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-11-04T15:21:18.000Z (about 3 years ago)
- Last Synced: 2024-06-21T16:54:39.411Z (5 months ago)
- Topics: chrome, chrome-browser, chrome-devtools-protocol, debugging-tool, headless-chrome, kotlin, protocol, remote, remote-control, remote-execution, rxjava, rxjava2
- Language: Kotlin
- Homepage:
- Size: 98 MB
- Stars: 75
- Watchers: 7
- Forks: 11
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-chrome-devtools - chrome-reactive-kotlin - reactive (rxjava 2.x), low-level client library in Kotlin (Chrome DevTools Protocol / Libraries for driving the protocol (or a layer above))
README
# chrome-reactive-kotlin v0.7.1
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/pl.wendigo/chrome-reactive-kotlin/badge.svg)](https://maven-badges.herokuapp.com/maven-central/pl.wendigo/chrome-reactive-kotlin) [![Javadocs](https://www.javadoc.io/badge/pl.wendigo/chrome-reactive-kotlin.svg)](https://www.javadoc.io/doc/pl.wendigo/chrome-reactive-kotlin) [![Tests](https://github.com/wendigo/chrome-reactive-kotlin/actions/workflows/tests-with-gradle.yml/badge.svg)](https://github.com/wendigo/chrome-reactive-kotlin/actions/workflows/tests-with-gradle.yml) [![Update Status](https://github.com/wendigo/chrome-reactive-kotlin/workflows/Update%20protocol%20to%20ToT/badge.svg)](https://github.com/wendigo/chrome-reactive-kotlin/actions?workflow=Update+protocol+to+ToT) [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=wendigo/chrome-reactive-kotlin)](https://dependabot.com)
**chrome-reactive-kotlin** is a low level [Chrome DevTools Protocol](https://chromedevtools.github.io/debugger-protocol-viewer/) client written in [Kotlin](https://kotlinlang.org) and leveraging [RxJava3](https://github.com/ReactiveX/RxJava) 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](https://chromedevtools.github.io/debugger-protocol-viewer/tot/Target/) from [Target]((https://chromedevtools.github.io/debugger-protocol-viewer/tot/Target/)) domain and flatted sessions mode (see: [http://crbug.com/991325](http://crbug.com/991325)).
For debugging purposes you can use my other project: [chrome-protocol-proxy](https://github.com/wendigo/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/](https://wendigo.github.io/chrome-reactive-kotlin/).**
# Usage
## Gradle
`build.gradle`:
```groovy
implementation 'pl.wendigo:chrome-reactive-kotlin:0.7.1'
````build.gradle.kts`:
```kotlin
implementation("pl.wendigo:chrome-reactive-kotlin:0.7.1")
```## Maven
`pom.xml`:
```xml
pl.wendigo
chrome-reactive-kotlin
0.7.1```
# Example
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:
```kotlin
import pl.wendigo.chrome.api.page.NavigateRequestfun 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()
}
}
}
}
}
```