HeadlessBrowser

interface HeadlessBrowser

A browser running inside this app: no server, no cable, no visible UI.

Create one per host app and keep it for as long as automation is wanted. Creating it does not start a WebView; newPage does.

val browser = HeadlessBrowser.create(context, BrowserConfig())
val page = browser.newPage() // 1x1, text and DOM only
page.goto("https://example.com", WaitUntil.DomStable())
val title = page.title()
page.close()
browser.close()

Long-running automation belongs in a foreground service the host app owns. A WebView working in a backgrounded app can be throttled or killed, and this library does not take that decision on the app's behalf.

Types

Link copied to clipboard
object Companion

Where a HeadlessBrowser instance comes from; there is no public constructor.

Functions

Link copied to clipboard
abstract suspend fun capabilities(): Capabilities

What this device can actually do, from probing rather than from a version number.

Link copied to clipboard
abstract suspend fun close()

Closes every open session and releases everything. Safe to call twice.

Link copied to clipboard
abstract suspend fun newPage(viewport: Viewport? = null): Page

Opens a session.