PageImpl

class PageImpl : Page

Implementation of Page that delegates operations across engines via BackendRouter.

Functions

Link copied to clipboard
open suspend override fun addInitScript(script: String, allowedOrigins: Set<String>)

Installs a script that runs before any page script, on this and every subsequent document.

Link copied to clipboard
open suspend override fun blockResourceTypes(vararg types: ResourceType)

Blocks loading of specific resource categories (e.g. ResourceType.Images, ResourceType.Fonts).

Link copied to clipboard
fun blockTypes(vararg types: ResourceType)

Direct access to block resource types (images, fonts, media).

Link copied to clipboard
open suspend override fun capabilities(): Capabilities

What this session can do. Branch on it instead of discovering a gap through a failure.

Link copied to clipboard
open suspend override fun clearCookies(domain: String?)

Clears cookies for a domain, or all of them when domain is null.

Link copied to clipboard
open suspend override fun clearStorage()

Clears local storage, session storage and IndexedDB.

Link copied to clipboard
open suspend override fun click(selector: String, timeoutMillis: Long)

Waits for the element, scrolls it into view, then clicks it.

Link copied to clipboard
open suspend override fun close()

Destroys the session. Every path ends here, including cancellation and exceptions. Safe to call twice.

Link copied to clipboard
open suspend override fun content(): String

The document's serialised HTML. Subject to the same cap as text.

Link copied to clipboard
open suspend override fun cookies(url: String): List<Cookie>

Cookie storage is process-global: these are not scoped to this session.

Link copied to clipboard
open suspend override fun evaluate(expression: String, timeoutMillis: Long): String?

Evaluates an expression in page context and returns its value.

Link copied to clipboard
open suspend override fun exposeFunction(name: String, allowedOrigins: Set<String>, handler: suspend (String) -> String?)

Exposes a native function to page context, over an origin-scoped channel.

Link copied to clipboard
open suspend override fun fillTime(selector: String, time: String, timeoutMillis: Long)

Sets the value of a time-typed input, for example "14:30".

Link copied to clipboard
open suspend override fun frames(): List<Frame>

Reports only the main frame; the WebView does not expose child frames.

Link copied to clipboard
open suspend override fun goto(url: String, waitUntil: WaitUntil, timeoutMillis: Long): NavigationResult

Navigates and waits for waitUntil.

Link copied to clipboard
open suspend override fun hover(selector: String, timeoutMillis: Long)

Delegates to platformInputEngine.

Link copied to clipboard
open override fun onConsole(listener: (ConsoleMessage) -> Unit)

Not yet implemented: registered but never invoked.

Link copied to clipboard
open override fun onDialog(listener: suspend (Dialog) -> Unit)

Dialogs block the page until answered. Without a listener they are dismissed.

Link copied to clipboard
open override fun onRequest(listener: (Request) -> Unit)

Delegates to platformRouter, synthesizing a Request per intercepted URL.

Link copied to clipboard
open override fun onResponse(listener: (Response) -> Unit)

Not yet implemented: registered but never invoked.

Link copied to clipboard
open suspend override fun press(key: String, timeoutMillis: Long)

Presses a key against the focused element, for example Enter.

Link copied to clipboard
open suspend override fun querySelector(selector: String): Element
Link copied to clipboard
open suspend override fun querySelectorAll(selector: String): List<Element>

Empty when nothing matches. Unlike querySelector, this is not an error.

Link copied to clipboard
open suspend override fun route(pattern: String, handler: suspend (Route) -> Unit)

Routes requests matching a glob pattern, such as one selecting every png, jpg and woff2 under any path.

Link copied to clipboard
open suspend override fun screenshot(format: ImageFormat, quality: Int): ByteArray

Captures the viewport by drawing the view.

Link copied to clipboard
open suspend override fun scrollIntoView(selector: String, timeoutMillis: Long)

Delegates to platformInputEngine.

Link copied to clipboard
open suspend override fun selectOption(selector: String, value: String, timeoutMillis: Long)

Delegates to platformInputEngine.

Link copied to clipboard
open suspend override fun setCookie(cookie: Cookie)

Delegates to platformStorageEngine.

Link copied to clipboard
open suspend override fun setExtraHeaders(headers: Map<String, String>)

Not yet implemented: accepted but never applied to requests.

Link copied to clipboard
open suspend override fun setUserAgent(userAgent: String)

Sets the WebView's User-Agent string directly.

Link copied to clipboard
open suspend override fun text(): String

The rendered text of the document. Capped; oversized output is truncated and reported.

Link copied to clipboard
open suspend override fun title(): String

Delegates to backendRouter.

Link copied to clipboard
open suspend override fun type(selector: String, text: String, timeoutMillis: Long)

Types into the element, firing the input and change events a framework needs.

Link copied to clipboard
open suspend override fun url(): String

The document actually loaded, which after a redirect is not the requested URL.

Link copied to clipboard
open suspend override fun waitForFunction(expression: String, timeoutMillis: Long)

Waits until a JavaScript expression is truthy.

Link copied to clipboard
open suspend override fun waitForSelector(selector: String, timeoutMillis: Long): Element

Waits for an element to exist. Returns as soon as it appears, not on a poll tick.