KMPwright

Page

Complete reference of the Page interface and its public extension functions (selector conveniences, action-scoped waits, dialogs, tabs, agent commands), with every parameter and its default.

Page is one browser tab or WebView, modeled on Playwright's Page plus agent-browser's agent features. Get one from browser.page(), browser.newPage() or context.newPage().

val page = browser.newPage()
page.goto("https://example.com")
page.click("text=More information")             // extension: page.locator(selector).click()
val response = page.waitForResponse("**/api/*") { click("#load") }
expect(page).toHaveTitle(Regex("Example"))

Conventions:

  • Every operation is suspend unless marked otherwise below.
  • A timeoutMs of null uses the matching TimeoutConfig default. Timeouts throw KmpwrightTimeoutException.
  • Page extends ElementFinder, so it has locator, frameLocator and every getBy* method. They are listed on Locator.
  • Members marked "CDP only" throw KmpwrightUnsupportedException on Android and iOS. See Capabilities.
  • String URL parameters (route, unroute, waitForURL, waitForRequest, waitForResponse, waitForNavigation, waitForDownload, expect(page).toHaveURL) use Playwright's URL glob over the full URL: ** matches anything including /, * anything except /, {a,b} either alternative, \ escapes, and every other character (including ?) is literal. A string without glob characters is an exact URL ("https://example.com" equals https://example.com/); an empty string matches everything. Use "**/api/items" for a path on any host, the Regex overloads, or the KMPwright regex: prefix where only a String is accepted.

Source: Page.kt, PageConvenience.kt, PageWaits.kt.

Properties

All non-suspending.

PropertyTypeDescription
urlStateFlow<String?>Committed URL, updated on every navigation. Playwright: page.url().
titleStateFlow<String?>Document title as of the last navigation. Playwright: page.title().
eventsPageEventsHot event streams; see PageEvents. Playwright: page.on(...).
networkNetworkHistoryRecorded requests, response bodies and HAR capture (agent-browser network).
reactReactInspectorReact component tree, inspection, Suspense and render profiling (agent-browser react).
webMcpWebMcpWebMCP tools exposed by the page (agent-browser webmcp).
touchscreenTouchscreentap, longTap, scroll, swipe, pinch in CSS pixels.
mouseMousemove, click, dblclick, down, up, wheel, drag. Needs InputMode.Hybrid.
keyboardKeyboardinsertText, type, down, up, press. Needs InputMode.Hybrid.
localStorageWebStorageThe current origin's localStorage: get, set, remove, clear, entries.
sessionStorageWebStorageThe current origin's sessionStorage.
clipboardClipboardreadText(): String?, writeText(text).
tracingTracingstart(categories, screenshots, path), stop(): ByteArray?. CDP only. See tracing.start parameters.
profilerProfilerstart(), stop(): String? (V8 CPU profile JSON). CDP only.
videoVideostart(path, ...), stop(): RecordingResult. CDP only, needs ffmpeg. See video.start parameters.

Capabilities

MemberDescription
fun capabilities(): PageCapabilitiesWhat this backend supports.
fun requireCapabilities(vararg requirements: PageCapabilityRequirement): PageCapabilitiesThrows KmpwrightException unless every requirement is met.
fun requireCapabilities(vararg capabilities: PageCapability): PageCapabilitiesSame, requiring Supported for each.

See Capabilities.

MemberDescription
goto(url: String, waitUntil: LoadState = LoadState.Load, timeoutMs: Long? = null): NavigationResultNavigates the main frame and waits for waitUntil. A failed or blocked navigation returns ok = false with error; only a timeout throws.
reload(waitUntil: LoadState = LoadState.Load, timeoutMs: Long? = null): NavigationResultReloads and waits for the new document.
goBack(waitUntil: LoadState = LoadState.Load, timeoutMs: Long? = null): NavigationResult?Back in history; null when there is no previous entry.
goForward(waitUntil: LoadState = LoadState.Load, timeoutMs: Long? = null): NavigationResult?Forward in history; null when there is no next entry.
pushState(url: String, timeoutMs: Long? = null): NavigationResultClient-side navigation through the Next.js router or history.pushState (agent-browser pushstate). Needs allowEval.

NavigationResult(url: String, status: Int, ok: Boolean, error: String? = null): url is the final URL after redirects; status the HTTP status of the final response (200 for local documents such as setContent, 0 when the navigation failed); ok is Playwright's response.ok(): committed and status 200..299. A 404 or 500 page is committed with ok = false and error = null; error is set only when no document was committed (network error, policy, domain filter).

Waiting

MemberDescription
waitForURL(url: String, waitUntil: LoadState = LoadState.Load, timeoutMs: Long? = null)Until the URL matches the URL glob, then waits for waitUntil. Same-document navigations (pushState, hash changes) count.
waitForURL(url: Regex, waitUntil: LoadState = LoadState.Load, timeoutMs: Long? = null)Until the URL matches the regex.
waitForURL(waitUntil: LoadState = LoadState.Load, timeoutMs: Long? = null, predicate: (String) -> Boolean)Until predicate accepts the URL.
waitForLoadState(state: LoadState = LoadState.Load, timeoutMs: Long? = null)Until the document reaches state.
waitForTimeout(ms: Long)Suspends for ms.
waitForNavigation(url: String? = null, waitUntil: LoadState? = null, timeoutMs: Long? = null): NavigationResult?The next navigation; null when none happens in time. url is a URL glob (regex: prefix for a regular expression; null accepts any navigation); a non-null waitUntil also waits for that load state. Same-document navigations count. Prefer the action-scoped form below.
waitForEvent(event: String, timeoutMs: Long? = null, predicate: ((Any?) -> Boolean)? = null): Any?Next event accepted by predicate (any event when null; not applied to load-state events) named console, navigation, dialog, request, response, download, filechooser, pageerror, domcontentloaded, load or networkidle (case-insensitive); null on timeout. Other names throw "Unsupported page event: name". Waiting for dialog routes dialogs to automation on Android.
waitForFunction(expression: String, timeoutMs: Long? = null): JsResultUntil expression is truthy; returns its value. Needs allowEval.
waitForText(text: String, timeoutMs: Long? = null)Until text appears in document.body.innerText (agent-browser wait --text). Throws on timeout.
waitForRequest(url: String, timeoutMs: Long? = null): RequestNext request whose URL matches the URL glob.
waitForRequest(url: Regex, timeoutMs: Long? = null): RequestNext request matching the regex.
waitForRequest(timeoutMs: Long? = null, predicate: (Request) -> Boolean): RequestNext request accepted by predicate.
waitForResponse(url: String, timeoutMs: Long? = null): ResponseNext response whose URL matches the URL glob. A failed request arrives as status 0 with the error in statusText.
waitForResponse(url: Regex, timeoutMs: Long? = null): ResponseNext response matching the regex.
waitForResponse(timeoutMs: Long? = null, predicate: (Response) -> Boolean): ResponseNext response accepted by predicate.
waitForDownload(url: String? = null, timeoutMs: Long? = null): DownloadNext download, optionally matching a URL glob. CDP only.
waitForFileChooser(timeoutMs: Long? = null): FileChooserNext file chooser. CDP only; call setFileChooserInterception() first.

Action-scoped waits (extensions)

Playwright's Promise.all([page.waitForX(), action()]) in one call: the wait subscribes before action runs, so a fast event cannot be missed. action has the page as receiver.

ExtensionReturns
Page.waitForNavigation(url: String? = null, waitUntil: LoadState? = null, timeoutMs: Long? = null, action: suspend Page.() -> Unit)NavigationResult; throws KmpwrightTimeoutException when no navigation happens.
Page.waitForRequest(url: String, timeoutMs: Long? = null, action: suspend Page.() -> Unit)Request
Page.waitForRequest(url: Regex, timeoutMs: Long? = null, action: suspend Page.() -> Unit)Request
Page.waitForResponse(url: String, timeoutMs: Long? = null, action: suspend Page.() -> Unit)Response
Page.waitForResponse(url: Regex, timeoutMs: Long? = null, action: suspend Page.() -> Unit)Response
Page.waitForURL(url: String, waitUntil: LoadState = LoadState.Load, timeoutMs: Long? = null, action: suspend Page.() -> Unit)Unit
Page.waitForURL(url: Regex, waitUntil: LoadState = LoadState.Load, timeoutMs: Long? = null, action: suspend Page.() -> Unit)Unit
Page.waitForURL(predicate: (String) -> Boolean, waitUntil: LoadState = LoadState.Load, timeoutMs: Long? = null, action: suspend Page.() -> Unit)Unit
Page.waitForDownload(url: String? = null, timeoutMs: Long? = null, action: suspend Page.() -> Unit)Download
Page.waitForFileChooser(timeoutMs: Long? = null, action: suspend Page.() -> Unit)FileChooser
Page.waitForDialog(timeoutMs: Long? = null, action: suspend Page.() -> Unit)DialogEvent
val nav = page.waitForNavigation { click("text=Next") }
val response = page.waitForResponse(Regex("/api/items")) { click("#load") }

Content and scripts

MemberDescription
evaluate(expression: String): JsResultEvaluates JavaScript in the page; Promises are awaited. Needs allowEval.
content(): StringThe document's full HTML. Needs allowDomExtraction.
setContent(html: String, waitUntil: LoadState = LoadState.Load, timeoutMs: Long? = null)Replaces the document with html and waits for waitUntil.
screenshot(fullPage: Boolean = false, clip: Rectangle? = null, omitBackground: Boolean = false, quality: Int = 90, format: ScreenshotFormat = ScreenshotFormat.Png, scale: Double = 1.0, annotate: Boolean = false, timeoutMs: Long? = null): ScreenshotResultViewport, full page or clip; see screenshot parameters. With annotate = true, snapshot refs are drawn and returned in annotations (agent-browser screenshot --annotate).
pdf(format: PdfFormat? = null, landscape: Boolean = false, displayHeaderFooter: Boolean = false, headerTemplate: String = "", footerTemplate: String = "", printBackground: Boolean = true, scale: Double = 1.0, width: Double? = null, height: Double? = null, margin: PdfMargin = PdfMargin(), pageRanges: String = "", timeoutMs: Long? = null): PdfResultRenders the page as PDF (PdfResult.bytes). Parameters are limited on Android and iOS; see pdf parameters.
fun screencast(maxFps: Int = 30, quality: Int = 80, maxWidth: Int = 1920, maxHeight: Int = 1080): Flow<ScreencastFrame>Experimental, latest-frame-wins JPEG frames. Non-suspending. CDP only.
addInitScript(script: String): StringRuns script before page scripts in later documents and child frames; returns an id.
removeInitScript(id: String)Removes an init script. Unknown ids throw "Unknown init-script identifier: id".
addScriptTag(url: String? = null, content: String? = null, type: String = "text/javascript", id: String = "", async: Boolean = false, defer: Boolean = false): StringAdds a <script>; returns its element id (id, or a generated one when empty). Needs url or content.
addStyleTag(url: String? = null, content: String? = null, id: String = ""): StringAdds a <style> or stylesheet <link>; returns its element id. Needs url or content.
read(url: String? = null, raw: Boolean = false, requireMarkdown: Boolean = false, llms: LlmsReadMode? = null, outline: Boolean = false, filter: String? = null, headers: Map<String, String> = emptyMap(), allowedDomains: Set<String> = emptySet(), maxBytes: Int = 2 * 1024 * 1024, caCertificatePath: String? = null, useSystemCa: Boolean = true, timeoutMs: Long? = null): ReadResultFetches url over HTTP (or reads this page when null) as readable text or Markdown (agent-browser read). See read parameters.
webVitals(url: String? = null, reload: Boolean = true, settleMs: Long = 3_000, timeoutMs: Long? = null): WebVitalsReportCore Web Vitals (agent-browser vitals). See webVitals parameters.
metrics(): PageMetricsRuntime metrics: documents, frames, jsHeapUsedSize, jsHeapTotalSize, resources, networkIdle.
serviceWorkers(): List<ServiceWorker>Registrations (url, state, scriptUrl, unregister()). CDP only.
accessibilityAudit(tags: Set<String> = emptySet(), selector: String? = null, maxNodesPerRule: Int = 10, timeoutMs: Long? = null): AccessibilityAuditReportaxe-core audit of the document (or of selector). tags are axe rule tags such as wcag2a/wcag2aa (empty runs all enabled rules); at most maxNodesPerRule nodes are reported per rule.
fun consoleMessages(filter: PageMessageFilter = PageMessageFilter.SinceNavigation): List<ConsoleMessage>Up to the last 200 console messages. SinceNavigation returns those after the last committed main-frame navigation (Playwright's default); All returns every stored one.
fun pageErrors(filter: PageMessageFilter = PageMessageFilter.SinceNavigation): List<String>Up to the last 200 uncaught exceptions and unhandled promise rejections (not console.error), formatted "Name: message". Structured form: events.pageError.
fun clearConsoleMessages()Forgets stored console messages.
fun clearPageErrors()Forgets stored page errors.
fun mainFrame(): FrameLocatorThe main frame as a FrameLocator. Non-suspending.

JsResult(value: String, type: String): value is the string itself for strings and JSON for everything else ("null" for null and undefined); type is the JavaScript typeof, with "null" for null and "array" for arrays. Playwright returns deserialized values; parse value yourself.

Agent features

MemberDescription
snapshot(interactive: Boolean = false, compact: Boolean = false, maxDepth: Int? = null, selector: String? = null, cursor: Boolean = false, includeHidden: Boolean = false, urls: Boolean = false): SnapshotAccessibility snapshot (agent-browser snapshot); see snapshot parameters. Interactive elements get refs like @e3 that locator("@e3") accepts until the next snapshot or navigation. Returns Snapshot(tree, refs, nodes).
diffSnapshot(before: Snapshot, after: Snapshot): SnapshotDiffResultLine diff of two snapshots (agent-browser diff snapshot).
diffSnapshot(name: String): SnapshotDiffResultSnapshots now, diffs against the snapshot saved under name, then saves the new one. The first call records a baseline and reports no change.
diffUrls(url1: String, url2: String, timeoutMs: Long? = null): SnapshotDiffResultDiffs the text structure of two URLs fetched over HTTP (agent-browser diff url).
fun createContentBoundary(): ContentBoundaryA boundary with a fresh nonce for wrapping untrusted page content. Non-suspending.
boundedContent(boundary: ContentBoundary? = null): StringPage HTML wrapped in boundary markers (agent-browser --content-boundaries).
boundedSnapshot(interactive: Boolean = false, compact: Boolean = false, maxDepth: Int? = null, selector: String? = null, cursor: Boolean = false, includeHidden: Boolean = false, urls: Boolean = false, boundary: ContentBoundary? = null): StringSnapshot tree wrapped in boundary markers; the snapshot parameters are those of snapshot.
fun setActionPolicy(policy: ActionPolicy)Applies an allow/deny/confirm policy to every later action (agent-browser --action-policy). See ActionPolicy.
fun setPolicyConfirmCallback(callback: (suspend (ActionType, String?) -> Boolean)?)Answers actions the policy marks Confirm (agent-browser --confirm-actions).
setAllowedDomains(domains: List<String>)Restricts the hosts the page may contact (agent-browser --allowed-domains). *.example.com matches the apex and subdomains; an empty list removes the restriction. Enforcement differs per backend; see DomainFiltering.
login(profile: AuthProfile, navigate: Boolean = true, submit: Boolean = true): AuthLoginResultFills and submits the login form described by profile (agent-browser auth login). navigate first opens the saved profile URL (false fills the already-open login document); submit = false fills without submitting. submitted does not prove success.
Page.runCommand(command: String): AgentCommandResult (extension)Runs one agent-browser command line, for example "click @e3". Returns AgentCommandResult(command, output, snapshot, screenshot). Throws KmpwrightException for unknown or malformed commands. See Commands.
Page.visualDiff(expected: ScreenshotResult, actual: ScreenshotResult, threshold: Double = 0.1, generateDiffImage: Boolean = true): DiffResult (extension)Pixel comparison of two screenshots (agent-browser diff screenshot). Images of different sizes report dimensionMismatch; undecodable images (for example WEBP on the JVM) throw KmpwrightException.

Network

MemberDescription
route(url: String, handler: suspend (Route) -> Unit)Intercepts requests matching the URL glob. The handler calls fulfill, abort, resume or fallback; returning without a decision falls back. The newest matching route runs first. Registering the same url replaces its handler. Returns once interception is active.
route(url: Regex, handler: suspend (Route) -> Unit)Intercepts requests whose full URL matches the regex.
unroute(url: String)Removes the route registered for that glob.
unroute(url: Regex)Removes the route registered for that regex.
unrouteAll()Removes every route.
fun onDialog(handler: suspend (DialogEvent) -> DialogResponse): DialogHandlerAnswers JavaScript dialogs; the newest handler wins. DialogHandler.close() removes it. A handler that does not answer within TimeoutConfig.handler dismisses the dialog. Non-suspending.
setExtraHTTPHeaders(headers: Map<String, String>)Sends headers with every request. Android and iOS only accept an empty map.
setHTTPCredentials(credentials: HttpCredentials?)Answers HTTP authentication with HttpCredentials(username, password); null clears.
setFileChooserInterception(enabled: Boolean = true)Enables native file chooser interception. CDP only; required before waitForFileChooser.
setDownloadPath(path: String)Directory where downloads are saved. CDP only.
setDownloadBehavior(behavior: DownloadBehavior)SaveToDownloadPath, Deny or Allow. CDP only.

Route has request: Request and fulfill(status = 200, headers = emptyMap(), body = null, bodyBytes = null, contentType = null, json = null) (json is an already-serialized body that cannot be combined with body/bodyBytes; bodyBytes wins over body), abort(errorCode = "failed"), resume(url = null, method = null, headers = null, postData = null) (Playwright route.continue()) and fallback(). A handler decides once; a second decision throws "Route is already handled". Handlers are bounded by TimeoutConfig.handler. See Network.

Dialog helpers (extensions)

ExtensionDescription
fun Page.acceptDialogs(): DialogHandlerAccepts every dialog until the handle is closed.
fun Page.dismissDialogs(): DialogHandlerDismisses every dialog until the handle is closed.
fun Page.acceptDialogsIf(predicate: (DialogEvent) -> Boolean): DialogHandlerAccepts matching dialogs and dismisses the rest.
suspend fun Page.waitForDialog(timeoutMs: Long? = null): DialogEventThe next dialog (Playwright waitForEvent('dialog')). While waiting it counts as a dialog listener, so dialogs reach automation even on Android. It is answered by the newest onDialog handler, or dismissed.

DialogEvent(type: DialogType, message: String, defaultPrompt: String? = null) with DialogType Alert, Confirm, Prompt, BeforeUnload. DialogResponse is Accept, Dismiss or Text(text) (accepts a prompt with text). Without a handler, dialogs are dismissed on iOS and JVM and left to the WebView's own UI on Android.

Cookies and storage state

MemberDescription
cookies(urls: List<String> = emptyList()): List<Cookie>Cookies visible to urls, or every cookie when empty. Playwright: context.cookies().
addCookies(cookies: List<Cookie>)Adds or replaces cookies.
clearCookies(name: String? = null, domain: String? = null)Removes matching cookies; both null removes all.
storageState(): StorageStateCookies plus this origin's localStorage and sessionStorage. StorageState.save(path, password) writes it (password null = plaintext).
setStorageState(state: StorageState)Replaces cookies, navigates to the state's URL when needed, restores storage. Use with StorageState.load(path, password).
autosaveStorageState(path: String, password: String?, intervalMs: Long = 30_000): StorageStateAutosaveSaves immediately, then every intervalMs (one second to one day) until stop() or the page closes. password has no default: pass null explicitly for plaintext. Blank path or password throws IllegalArgumentException. The handle exposes error, lastSavedAt and isActive.

Cookie(name, value, domain, path = "/", expires: Double? = null, secure = false, httpOnly = false, sameSite: String? = null, hostOnly = !domain.startsWith(".")); expires is Unix epoch seconds, null for a session cookie.

Emulation

MemberDescription
emulateMedia(colorScheme: ColorScheme?)prefers-color-scheme: Light, Dark, NoPreference; null resets. Native on CDP and on iOS when the view is in a window, JavaScript otherwise.
setGeolocation(geolocation: Geolocation?)Overrides navigator.geolocation; null resets.
setOffline(offline: Boolean)Emulates being offline.
emulateNetworkConditions(conditions: NetworkConditions?)Throttling; null removes it. WebViews only emulate offline and throw KmpwrightUnsupportedException for latency or throughput.
setUserAgent(userAgent: String)User agent for later requests.
setViewportSize(width: Int, height: Int)Viewport in CSS pixels (Android, JVM) or points (iOS).
fun viewportSize(): ViewportSizeCurrent viewport in CSS pixels. Never null. Non-suspending.
setDeviceScaleFactor(scale: Double)Device pixel ratio. Android and iOS throw.
emulateDevice(device: DeviceDescriptor)Applies a preset such as Devices.iPhone15: viewport size and user agent on every backend, plus scale factor, mobile layout and touch on CDP. Android and iOS keep the display's scale factor and native touch. Nothing is applied when the descriptor is invalid (IllegalArgumentException).

Scrolling

MemberDescription
scroll(direction: ScrollDirection, amount: Double = 300.0)Scrolls by amount CSS pixels Up, Down, Left or Right (agent-browser scroll).
scrollToTop()Scrolls to the top.
scrollToBottom()Scrolls to the bottom.

Tabs and lifecycle

MemberDescription
openNewTab(url: String? = null): NavigationResultOpens a new page that inherits this page's routes and emulation and navigates it to url (about:blank when null).
close()Closes the page and waits for its resources to be released. Idempotent. Playwright: page.close().
fun dispose()Non-suspending, best-effort teardown for lifecycle callbacks (Compose onDispose, Activity.onDestroy). Returns immediately; prefer close().

After close(), page operations throw KmpwrightException: "Page is closed".

Browser extensions for tabs (agent-browser tab): fun Browser.tabList(): List<TabInfo(index, url, page)>, fun Browser.switchToTab(index: Int): Page, suspend fun Browser.closeTab(index: Int). Out-of-range indexes throw "Tab index N out of range (0..M)".

Browser, BrowserContext, Page and LaunchedBrowser each have suspend inline fun <T> X.use(block: (X) -> T): T, which runs block and then closes the receiver even when block throws or the coroutine is cancelled (the close runs in NonCancellable), like Kotlin's Closeable.use and Ktor's HttpClient.use:

browser.newPage().use { page ->
    page.goto("https://example.com")
    page.click("button.submit")
}

Selector conveniences (extensions)

Playwright's page.click(selector) family. Each one is page.locator(selector).<action>(...); selectors also accept snapshot refs (@e3, e3, ref=e3).

ExtensionEquivalent
Page.click(selector: String, button: MouseButton = MouseButton.Left, clickCount: Int = 1, delayMs: Long = 0, position: Position? = null, force: Boolean = false, timeoutMs: Long? = null)locator(selector).click(button, clickCount, delayMs, position, force, timeoutMs)
Page.dblclick(selector: String, button: MouseButton = MouseButton.Left, delayMs: Long = 0, position: Position? = null, force: Boolean = false, timeoutMs: Long? = null).dblclick(button, delayMs, position, force, timeoutMs)
Page.tap(selector: String, force: Boolean = false, modifiers: Int = 0, timeoutMs: Long? = null).tap(force, modifiers, timeoutMs)
Page.fill(selector: String, value: String, force: Boolean = false, timeoutMs: Long? = null).fill(value, force, timeoutMs)
Page.clear(selector: String, force: Boolean = false, timeoutMs: Long? = null).clear(force, timeoutMs)
Page.type(selector: String, text: String, delayMs: Long = 0, timeoutMs: Long? = null).pressSequentially(text, delayMs, timeoutMs)
Page.press(selector: String, key: String, delayMs: Long = 0, timeoutMs: Long? = null).press(key, delayMs, timeoutMs)
Page.hover(selector: String, force: Boolean = false, timeoutMs: Long? = null).hover(force, timeoutMs)
Page.focus(selector: String, timeoutMs: Long? = null).focus(timeoutMs)
Page.highlight(selector: String, color: String = "rgba(255, 0, 0, 0.3)", borderColor: String = "red", durationMs: Long = 3000).highlight(color, borderColor, durationMs) (agent-browser highlight)
Page.check(selector: String, force: Boolean = false, timeoutMs: Long? = null).check(force, timeoutMs)
Page.uncheck(selector: String, force: Boolean = false, timeoutMs: Long? = null).uncheck(force, timeoutMs)
Page.setChecked(selector: String, checked: Boolean, force: Boolean = false, timeoutMs: Long? = null).setChecked(checked, force, timeoutMs)
Page.selectOption(selector: String, value: String, force: Boolean = false, timeoutMs: Long? = null).selectOption(value, force, timeoutMs)
Page.selectOption(selector: String, values: List<String>, force: Boolean = false, timeoutMs: Long? = null).selectOption(values, force, timeoutMs)
Page.setInputFiles(selector: String, files: List<String>, force: Boolean = false, timeoutMs: Long? = null).setInputFiles(files, force, timeoutMs) (agent-browser upload)
Page.dragAndDrop(source: String, target: String, sourcePosition: Position? = null, targetPosition: Position? = null, timeoutMs: Long? = null)locator(source).dragTo(locator(target), sourcePosition, targetPosition, timeoutMs) (agent-browser drag)
Page.dispatchEvent(selector: String, type: String, timeoutMs: Long? = null).dispatchEvent(type, timeoutMs)

Queries wait for the element to be attached first (TimeoutConfig.waitForSelector when timeoutMs is null), like Playwright:

ExtensionReturns
Page.textContent(selector: String, timeoutMs: Long? = null)String?
Page.innerText(selector: String, timeoutMs: Long? = null)String
Page.innerHTML(selector: String, timeoutMs: Long? = null)String
Page.getAttribute(selector: String, name: String, timeoutMs: Long? = null)String?
Page.inputValue(selector: String, timeoutMs: Long? = null)String?

State checks do not wait:

ExtensionReturns
Page.isVisible(selector: String)Boolean; false when nothing matches.
Page.isHidden(selector: String)Boolean; true when nothing matches.
Page.isEnabled(selector: String)Boolean; throws when nothing matches.
Page.isDisabled(selector: String)Boolean; throws when nothing matches.
Page.isChecked(selector: String)Boolean; throws when nothing matches.
Page.isEditable(selector: String)Boolean; throws when nothing matches.
Page.count(selector: String)Int (agent-browser get count).
Page.waitForSelector(selector: String, state: SelectorState = SelectorState.Visible, timeoutMs: Long? = null)Unit. States: Attached, Detached, Visible, Hidden.
Page.paste()Inserts the clipboard text into the focused element (agent-browser clipboard paste).

Other public functions that take a Page

FunctionDescription
fun Page.androidWebViewState(): StateFlow<AndroidWebViewState>?Android only. See Android.
suspend fun resetPageForReuse(page: Page)Clears routes, allowed domains, credentials, headers, cookies and storage, then navigates to about:blank. Same-owner reuse only.
fun expect(page: Page): PageAssertionsSee Assertions.

PageEvents

Hot, non-replaying SharedFlows. Subscribe before triggering the action, or use the action-scoped waits.

PropertyType
consoleSharedFlow<ConsoleMessage> (type, text, location: SourceLocation?)
navigationSharedFlow<NavigationEvent> (url, status, navigationType: SameDocument or NewDocument)
loadStateSharedFlow<LoadState>
dialogSharedFlow<DialogEvent>
requestSharedFlow<Request>
responseSharedFlow<Response> (failed requests: status 0, error in statusText)
downloadSharedFlow<Download>
fileChooserSharedFlow<FileChooser>
pageErrorSharedFlow<PageError>: uncaught exceptions and unhandled promise rejections (Playwright pageerror)

Collecting dialog does not register a dialog listener: on Android a dialog is only emitted while an onDialog handler or a waitForDialog is active.

PageError(name, message, stack: String? = null, location: SourceLocation? = null) has text ("Name: message", or the message when name is empty). ConsoleMessage.type is one of Playwright's values: log, debug, info, error, warning, dir, dirxml, table, trace, clear, startGroup, startGroupCollapsed, endGroup, assert, profile, profileEnd, count, timeEnd. PageMessageFilter is SinceNavigation or All.

Download has url, suggestedFilename, path(): String? and saveAs(path) (throws when no download path was set). FileChooser has isMultiple and setFiles(files) (an empty list cancels).

Parameters

Options are Kotlin named parameters: Playwright's page.screenshot({ fullPage: true }) is page.screenshot(fullPage = true). Where a method takes timeoutMs: Long? = null, it follows the other parameters; only a trailing lambda (predicate, action) comes after it.

goto, reload, goBack, goForward, setContent and waitForURL share these parameters:

Prop

Type

waitForNavigation:

Prop

Type

waitForEvent (after event):

Prop

Type

screenshot parameters

Locator.screenshot takes omitBackground, quality, format, scale and timeoutMs (no fullPage, clip or annotate).

Prop

Type

ScreenshotResult(bytes, width, height, annotations: List<Annotation(ref, role, name, box)>). ScreenshotResult.toRgbaImage(): RgbaImage? decodes it.

pdf parameters

Prop

Type

addScriptTag and addStyleTag parameters

Prop

Type

snapshot parameters

Also the first seven parameters of boundedSnapshot.

Prop

Type

SnapshotDiffResult(unifiedDiff, additions, removals, unchanged, changed).

read parameters

HttpReader(config).read(url, ...) takes the same parameters after a required url and works without a page and without browser cookies.

Prop

Type

ReadResult(url, finalUrl, status, contentType, source, truncated, content, headers).

webVitals parameters

Prop

Type

screencast parameters

Prop

Type

tracing.start parameters

Prop

Type

video.start parameters

Prop

Type

Emulation values

TypeFields and presets
Geolocationlatitude (-90..90), longitude (-180..180), accuracy = 0.0
NetworkConditionsoffline = false, latencyMs = 0, downloadThroughput = 0, uploadThroughput = 0 (bytes per second, 0 = unthrottled). Presets Slow3G, Fast3G, Offline.
HttpCredentialsusername, password (masked in toString())
DeviceDescriptorname, viewport: Viewport, userAgent. Presets in Devices.
ViewportSizewidth, height

On this page