DocsBrowser API

Browser API

agent.browsers reaches the browsers connected through the Tilda extension. The API follows Playwright’s shape, but it’s a supported subset: a method that isn’t listed here isn’t available. Your browser explains how agents share your browser.

The browser-api document#

Agents read this as agent.documentation.get("browser-api"). It’s written to them, and shown as they read it.

This is a Playwright-shaped subset. Do not assume that an undocumented Playwright method or option is available.

Runtime#

agent.browsers          getDefault(options?) get(id, options?) list()
agent.documentation     get(name) list() catalog()
agent.terminals         open(name, cmd, opts?) get(name) list() killAll()
agent.viewImage(value, {mimeType?})
agent.cwd               current working directory string
agent.homeDir           home directory string
agent.tmpDir            temporary directory string
expect(locator|page)    supported Playwright-style assertions

agent.browsers.list() returns [{id, name}]. getDefault() works only when exactly one browser is connected.

Deliberate differences from Playwright#

  • Browser contexts are tab groups in the user's signed-in Chrome profile, so contexts share cookies and storage.

  • An unhandled JavaScript dialog blocks the session and interrupts the current cell instead of being auto-dismissed.

  • Downloads are saved in the user's Downloads folder.

  • agent.browsers and its list, get, and getDefault methods are Tilda APIs, not Playwright APIs.

Password managers and other extensions can briefly insert a frame that makes Chrome detach its debugger. Tilda neutralises that frame and restores the same page session. The command in flight throws SessionInterruptedError instead of being retried: it may already have taken effect, so inspect the page state before deciding whether to repeat it. Later commands wait for session setup to be replayed and then continue normally.

Browser and context#

browser                 id name
browser                 isConnected() version() close()
browser                 newContext({title}) contexts() pages()
browser                 waitForDownload(options?, page?)
browser                 newCDPSession(page) newBrowserCDPSession()
BrowserContext          browser() newPage() pages() close()
BrowserContext          newCDPSession(page)

newContext({title}) makes one Chrome tab group named <agent label> · <title>, not an isolated browser profile. title is required and must not be empty. pages() and contexts() are synchronous. newPage() is asynchronous and opens a blank tab in the background, without changing the tab the user is viewing. page.goto(url) navigates it. Every page behaves as the focused, visible one while it stays in the background, so reading, screenshots, and input never need it in front. page.bringToFront() is synthetic and leaves the user's tab and apps as they are. Call page.bringToFrontForUser(), which switches the user's Chrome to the tab and raises its window, only when the user asked to see the page. goto reports a navigation that fails and waits for the document it asked for, so the page it hands back is the requested one. goto, reload, goBack, and goForward return the main-resource Response, or null for same-document navigation or when history cannot move.

Page#

page properties         id browser mouse keyboard
page identity           context() url() title() isClosed() close() bringToFront() bringToFrontForUser()
page navigation         goto() reload() goBack() goForward()
page content            content() setContent() evaluate() ariaSnapshot()
page display            screenshot() pdf() viewportSize() setViewportSize() screencast
page timeouts           setDefaultTimeout() setDefaultNavigationTimeout()
page waits              waitForLoadState(options) waitForURL() waitForTimeout()
                        waitForFunction() waitForNavigation() waitForResponse()
page locators           locator() getByRole() getByText() getByLabel()
                        getByPlaceholder() getByTestId() getByAltText()
                        getByTitle() frameLocator()
page selector helpers   click() dblclick() hover() fill() type() press()
                        check() uncheck() setChecked() selectOption()
                        focus() blur() clear() getAttribute() innerText()
                        innerHTML() textContent() selectText() inputValue()
                        isVisible() isHidden() isEnabled() isDisabled()
                        isEditable() isChecked() setInputFiles()
                        scrollIntoViewIfNeeded() waitForSelector()
                        $() $$() $eval() $$eval()
page frames             frames() mainFrame() frame()
page extras             dragAndDrop() dispatchEvent() addScriptTag() addStyleTag()
page events             on() off() waitForEvent() consoleMessages()
page network            route() unroute() unrouteAll()

Important differences:

  • Call await page.waitForLoadState({state, timeout}). The first argument is an options object.

  • Call await page.frames(), await page.mainFrame(), and await page.frame(...). These methods return promises.

  • page.url(), page.context(), page.viewportSize(), and page.isClosed() are synchronous.

  • Page selector helpers act on the first match by default. Pass {strict: true} to reject multiple matches. Locators remain strict.

  • A timeout of 0 disables the timeout, including default action, navigation, event, and assertion timeouts.

  • Same-origin frames work. Cross-origin frames do not.

  • page.pdf() needs a headless browser.

Screencast#

page.screencast records the rendered page viewport, not the browser chrome or desktop, and does not record audio. A recording continues across cells until stop(), page close, or kernel reset. A file path must be absolute, end in .webm, and not already exist. onFrame receives JPEG frames while path receives the browser-encoded VP8 WebM stream; either output or both is required.

await page.screencast.start({
  path: "/absolute/path/demo.webm",
  size: { width: 1280, height: 800 },
  quality: 80,
  fps: 25,
  onFrame: ({ data, timestamp, viewportWidth, viewportHeight }) => {},
});
await page.screencast.showActions({ position: "bottom-right" });
await page.screencast.showChapter("Checkout", { description: "Submitting the order" });
const overlay = await page.screencast.showOverlay("<div>Draft</div>");
// ... interact with the page ...
overlay[Symbol.dispose]();
await page.screencast.hideActions();
await page.screencast.stop();

start() accepts quality from 0–100, fps from 1–60, and positive output dimensions up to 16384. Defaults are quality 90, 25 fps, and the page viewport scaled down to fit within 800×800. If another consumer such as the live viewer already owns the page's CDP screencast, its size and quality remain authoritative; both consumers receive the same frames.

showOverlay(html, {duration?}) returns a disposable. showChapter(title, {description?, duration?}) defaults to 2000 ms. showOverlays() and hideOverlays() preserve overlays while changing visibility. showActions() returns a disposable and supports duration, position, fontSize, cursor, and CSS declaration strings under style.point, style.highlight, and style.title; hideActions() removes its current annotation.

Assertions#

Supported locator assertions are toBeVisible, toBeHidden, toBeAttached, toBeEnabled, toBeDisabled, toBeChecked, toBeEditable, toHaveCount, toHaveText, toContainText, toHaveValue, and toHaveAttribute. Supported page assertions are toHaveURL and toHaveTitle. Use .not to negate an assertion. String expectations for toHaveText, toHaveURL, and toHaveTitle are normalized full matches; use toContainText for substrings. Text assertions accept arrays that mix strings and regular expressions, and support ignoreCase and useInnerText. The default assertion timeout is 5 seconds, is a bound for the whole assertion, and 0 means no timeout.

The locators document#

Agents read this as agent.documentation.get("locators"). It’s written to them, and shown as they read it.

Locators are lazy and chainable. Actions are strict. An action fails if the locator matches more than one element. Narrow it with filter({hasText}), first(), last(), or nth(index).

Create and combine locators with locator, getByRole, getByText, getByLabel, getByPlaceholder, getByTestId, getByAltText, getByTitle, frameLocator, filter, and, and or.

Read with count, all, allTextContents, allInnerTexts, innerHTML, innerText, textContent, inputValue, getAttribute, boundingBox, isVisible, isHidden, isEnabled, isDisabled, isEditable, isChecked, ariaSnapshot, page, evaluate, and evaluateAll.

Act with click, dblclick, hover, fill, type, press, check, uncheck, setChecked, clear, blur, focus, pressSequentially, selectText, selectOption, scrollIntoViewIfNeeded, screenshot, setInputFiles, dispatchEvent, drop, dragTo, and waitFor.

locator.drop({files?, data?}) dispatches drag-and-drop events on that locator with a page-side DataTransfer. Use source.dragTo(target) to drag one locator to another. locator.ariaSnapshot() snapshots only that locator's element.

Text matchers accept a string or regular expression. Use {exact: true} for a full string match. Locator actions default to 15 seconds. Pass {timeout: 2000} for a short probe.

Use await page.ariaSnapshot() before you guess a selector. Each snapshot line ends in [ref=…], which works as a selector exactly as printed — page.locator("[ref=e1-865]") — and expires on navigation.

A click error that says another element intercepts the click means an overlay covers the target. Remove the overlay. Use {force: true} only when you must skip that check.

The network document#

Agents read this as agent.documentation.get("network"). It’s written to them, and shown as they read it.

Wait for a response that starts after the wait:

const [response] = await Promise.all([
  page.waitForResponse("/api/orders"),
  page.getByRole("button", {name: "Load"}).click(),
]);
const data = await response.json();

waitForResponse accepts a string, regular expression, or synchronous or asynchronous predicate. A predicate error rejects the wait. Responses support url(), status(), statusText(), ok(), headers(), allHeaders(), request(), body(), text(), and json().

Use page.route(pattern, handler) to handle later requests. route.abort() stops a request. route.continue() lets it continue. Use unroute(pattern, handler?) or unrouteAll() to remove routes.

The events document#

Agents read this as agent.documentation.get("events"). It’s written to them, and shown as they read it.

Supported page events are console, dialog, request, response, requestfinished, requestfailed, filechooser, pageerror, framenavigated, download, load, domcontentloaded, frameattached, framedetached, close, crash, and websocket.

Use page.on(event, handler) and page.off(event, handler) for listeners. page.removeListener(event, handler) is an alias for off. Use page.once(event, handler) when the handler must run one time. If the handler reference is unavailable, use await page.removeAllListeners(event). Pass {behavior: "wait"} to wait for handlers that are already running. Omitting the event removes all page listeners. Use await page.waitForEvent(event, {timeout, predicate?}) for one later event. page.consoleMessages() returns recent console messages.

Locator actions wait for elements. For page state, use await page.waitForLoadState({state: "load"|"domcontentloaded"|"networkidle", timeout}), waitForURL, waitForNavigation, waitForResponse, or waitForFunction. Use waitForTimeout only when no event or state can show that the page is ready.

The downloads document#

Agents read this as agent.documentation.get("downloads"). It’s written to them, and shown as they read it.

Start the wait before the action:

const [download] = await Promise.all([
  page.waitForEvent("download"),
  page.getByText("Export CSV").click(),
]);
const path = await download.path();
await download.saveAs("/tmp/export.csv");

A Download supports page(), url(), suggestedFilename(), path(), saveAs(path), failure(), cancel(), and delete(). The download event is emitted only on the page that started the download. path() and failure() wait for the terminal state, and cancellation and deletion report failures. Files land in the user's Downloads folder.

The files-and-dialogs document#

Agents read this as agent.documentation.get("files-and-dialogs"). It’s written to them, and shown as they read it.

For a file chooser, start the wait before the click:

const [chooser] = await Promise.all([
  page.waitForEvent("filechooser"),
  page.getByText("Upload").click(),
]);
await chooser.setFiles("/tmp/report.pdf");

A FileChooser supports page(), isMultiple(), and setFiles(files). You can also use locator.setInputFiles(files) or page.setInputFiles(selector, files).

A JavaScript dialog blocks page input. Register a handler before the action:

page.on("dialog", async dialog => {
  console.log(dialog.type(), dialog.message());
  await dialog.accept();
});
await page.getByText("Show alert").click();

A Dialog supports type(), message(), defaultValue(), page(), accept(promptText?), and dismiss().

There is no page.clipboard method. Use page.evaluate with navigator.clipboard only when the page already has the needed permission.

The cdp document#

Agents read this as agent.documentation.get("cdp"). It’s written to them, and shown as they read it.

Prefer the high-level API. For raw CDP, use await browser.newCDPSession(page) or await context.newCDPSession(page) for one page. Use await browser.newBrowserCDPSession() for browser-level commands.

A CDP session supports send(method, params?), on(event, handler), and detach(). Page CDP sessions are independent virtual sessions: detaching one removes only its listeners and never detaches the page or another session. Always detach a session when the task is complete.

Types#

As declared in the repl.d.ts the skills ship. Constructors are left out: code in a cell is handed these objects and doesn’t build them.

Browsers#

class Browsers {
	list(): Promise<BrowserListEntry[]>;
	/**
	 * Connect to a browser by id from `list()`, or by numeric index.
	 * @param id Browser id from `list()`, or a numeric index into that list.
	 * @param options How long to wait for the extension when none are connected yet.
	 */
	get(id: string | number, { timeoutMs }?: {
		timeoutMs?: number;
	}): Promise<Browser>;
	/**
	 * The only connected browser. Fails if none are connected, or if more than one is.
	 * @param options How long to wait for the extension when none are connected yet.
	 */
	getDefault({ timeoutMs }?: {
		timeoutMs?: number;
	}): Promise<Browser>;
}

SessionInterruptedError#

/**
 * A command was interrupted when a foreign extension frame detached Chrome's
 * debugger. The extension restored the session, but the command is never
 * replayed because it may already have changed the page.
 */
class SessionInterruptedError extends Error {
}

BrowserListEntry#

interface BrowserListEntry {
	id: string;
	name: string;
}

Browser#

class Browser {
	id: string;
	name: string;
	/**
	 * Playwright: browser.newContext().
	 * Each context is one Chrome tab group in the user's normal browser session.
	 * @param options Must include a non-empty `title` for the tab group.
	 */
	newContext(options: NewContextOptions): Promise<BrowserContext>;
	contexts(): BrowserContext[];
	/**
	 * Wait for a browser download that starts after this call.
	 * @param options `timeout` in ms; `since` epoch ms to ignore older downloads.
	 * @param page Optional page whose downloads should satisfy this wait.
	 */
	waitForDownload(options?: {
		timeout?: number;
		since?: number;
	}, page?: Page | null): Promise<Download>;
	/**
	 * Playwright: browserContext.newCDPSession(page) — also on Browser for compat.
	 * The page must belong to this browser (registered target).
	 */
	newCDPSession(page: Page): Promise<CDPSessionPublic>;
	/**
	 * Playwright: browser.newBrowserCDPSession().
	 */
	newBrowserCDPSession(): Promise<CDPSessionPublic>;
	/** Pages this agent holds across all contexts (sync). */
	pages(): Page[];
	isConnected(): boolean;
	version(): Promise<unknown>;
	close(): Promise<void>;
}

NewContextOptions#

interface NewContextOptions {
	title: string;
}

BrowserContext#

/**
 * Playwright-shaped browser context. In this bridge a context is one Chrome
 * tab group in the user's normal browser session.
 * @see https://playwright.dev/docs/api/class-browsercontext
 */
class BrowserContext {
	browser(): Browser;
	/**
	 * Playwright: browserContext.newCDPSession(page).
	 * The page must belong to this context.
	 */
	newCDPSession(page: Page): Promise<CDPSessionPublic>;
	/**
	 * Playwright: browserContext.newPage().
	 *
	 * The tab opens blank in the background and is attached before anything
	 * navigates, so `page.goto` can watch its own navigation from the start.
	 * Call `page.bringToFrontForUser()` when the user must see the tab.
	 */
	newPage(...args: unknown[]): Promise<Page>;
	pages(): Page[];
	close(): Promise<void>;
}

Page#

class Page {
	browser: Browser;
	id: string;
	mouse: Mouse;
	keyboard: Keyboard;
	readonly screencast: BrowserScreencast;
	locator(selector: string, options?: FilterOptions): Locator;
	getByRole(role: string, options?: RoleOptions): Locator;
	getByText(text: string | RegExp, options?: {
		exact?: boolean;
	}): Locator;
	getByLabel(text: string | RegExp, options?: {
		exact?: boolean;
	}): Locator;
	getByPlaceholder(text: string | RegExp, options?: {
		exact?: boolean;
	}): Locator;
	getByTestId(testId: string | RegExp): Locator;
	getByAltText(text: string | RegExp, options?: {
		exact?: boolean;
	}): Locator;
	getByTitle(text: string | RegExp, options?: {
		exact?: boolean;
	}): Locator;
	frameLocator(frameSelector: string): Locator;
	/**
	 * Playwright: page.context().
	 */
	context(): BrowserContext | null;
	evaluate(pageFunction: string | ((arg: unknown) => unknown), arg?: unknown, options?: TimeoutOptions): Promise<unknown>;
	waitForLoadState(options?: TimeoutOptions): Promise<void>;
	waitForURL(url: string | RegExp | ((url: string) => boolean), options?: TimeoutOptions): Promise<void>;
	waitForTimeout(timeoutMs: number): Promise<void>;
	waitForFunction(pageFunction: string | ((arg: unknown) => unknown), arg?: unknown, options?: TimeoutOptions): Promise<{}>;
	waitForNavigation(options?: TimeoutOptions): Promise<Response | null>;
	waitForResponse(urlOrPredicate: string | RegExp | ((response: Response) => boolean | Promise<boolean>), options?: TimeoutOptions): Promise<Response>;
	route(url: string | RegExp | ((url: string) => boolean), handler: RouteHandler): Promise<void>;
	unroute(url: string | RegExp | ((url: string) => boolean), handler?: RouteHandler): Promise<void>;
	unrouteAll(): Promise<void>;
	frames(): Promise<FrameHandle[]>;
	mainFrame(): Promise<FrameHandle>;
	frame(nameOrOptions?: string | {
		name?: string;
		url?: string | RegExp | ((url: string) => boolean);
	}): Promise<FrameHandle | null>;
	dragAndDrop(source: string, target: string, options?: TimeoutOptions): Promise<void>;
	addScriptTag(options?: {
		url?: string;
		content?: string;
		path?: string;
		type?: string;
	}): Promise<void>;
	addStyleTag(options?: {
		url?: string;
		content?: string;
		path?: string;
	}): Promise<void>;
	dispatchEvent(selector: string, type: string, eventInit?: Record<string, unknown>, options?: TimeoutOptions): Promise<void>;
	ariaSnapshot(options?: Record<string, unknown>): Promise<string>;
	/**
	 * Playwright page events.
	 */
	on(event: string, handler: (payload: unknown) => void): this;
	once(event: string, handler: (payload: unknown) => void): this;
	off(event: string, handler: (payload: unknown) => void): this;
	removeListener(event: string, handler: (payload: unknown) => void): this;
	removeAllListeners(event?: string, options?: {
		behavior?: RemoveAllListenersBehavior;
	}): Promise<void>;
	waitForEvent(event: string, options?: TimeoutOptions & {
		predicate?: (payload: unknown) => boolean | Promise<boolean>;
	}): Promise<unknown>;
	/**
	 * Playwright: page.consoleMessages().
	 */
	consoleMessages(options?: {
		type?: string | string[];
	}): ConsoleMessage[];
	click(selector: string, options?: TimeoutOptions): Promise<void>;
	dblclick(selector: string, options?: TimeoutOptions): Promise<void>;
	hover(selector: string, options?: TimeoutOptions): Promise<void>;
	fill(selector: string, value: string, options?: TimeoutOptions): Promise<void>;
	type(selector: string, value: string, options?: TimeoutOptions): Promise<void>;
	press(selector: string, value: string, options?: TimeoutOptions): Promise<void>;
	check(selector: string, options?: TimeoutOptions): Promise<void>;
	uncheck(selector: string, options?: TimeoutOptions): Promise<void>;
	setChecked(selector: string, checked: boolean, options?: TimeoutOptions): Promise<void>;
	selectOption(selector: string, value: string | string[] | {
		value?: string;
		label?: string;
		index?: number;
	} | Array<string | {
		value?: string;
		label?: string;
		index?: number;
	}>, options?: TimeoutOptions): Promise<string[]>;
	focus(selector: string, options?: TimeoutOptions): Promise<void>;
	blur(selector: string, options?: TimeoutOptions): Promise<void>;
	clear(selector: string, options?: TimeoutOptions): Promise<void>;
	getAttribute(selector: string, name: string, options?: TimeoutOptions): Promise<string | null>;
	innerText(selector: string, options?: TimeoutOptions): Promise<string>;
	innerHTML(selector: string, options?: TimeoutOptions): Promise<unknown>;
	textContent(selector: string, options?: TimeoutOptions): Promise<string | null>;
	selectText(selector: string, options?: TimeoutOptions): Promise<void>;
	inputValue(selector: string, options?: TimeoutOptions): Promise<string>;
	isVisible(selector: string, options?: TimeoutOptions): Promise<boolean>;
	isEnabled(selector: string, options?: TimeoutOptions): Promise<boolean>;
	isChecked(selector: string, options?: TimeoutOptions): Promise<boolean>;
	isDisabled(selector: string, options?: TimeoutOptions): Promise<boolean>;
	isEditable(selector: string, options?: TimeoutOptions): Promise<boolean>;
	isHidden(selector: string, options?: TimeoutOptions): Promise<boolean>;
	setInputFiles(selector: string, files: string | string[], options?: TimeoutOptions): Promise<void>;
	scrollIntoViewIfNeeded(selector: string, options?: TimeoutOptions): Promise<void>;
	waitForSelector(selector: string, options?: TimeoutOptions & {
		state?: string;
	}): Promise<Locator>;
	$(selector: string): Promise<Locator | null>;
	$$(selector: string): Promise<Locator[]>;
	$eval(selector: string, fn: (el: unknown, arg?: unknown) => unknown, arg?: unknown): Promise<unknown>;
	$$eval(selector: string, fn: (els: unknown[], arg?: unknown) => unknown, arg?: unknown): Promise<unknown>;
	/**
	 * Playwright: page.goto(url, options).
	 *
	 * The wait is tied to the loaderId that `Page.navigate` reports, so it
	 * describes the document that was asked for. Waiting on `document.readyState`
	 * instead would accept the document already on screen -- for a fresh tab that
	 * is `about:blank`, which is "complete" before the navigation even starts.
	 */
	goto(url: string, options?: TimeoutOptions): Promise<Response | null>;
	reload(options?: TimeoutOptions): Promise<Response | null>;
	goBack(options?: TimeoutOptions): Promise<Response | null>;
	goForward(options?: TimeoutOptions): Promise<Response | null>;
	content(): Promise<unknown>;
	setContent(html: unknown, options?: TimeoutOptions): Promise<void>;
	setDefaultTimeout(timeout: number): void;
	setDefaultNavigationTimeout(timeout: number): void;
	isClosed(): boolean;
	viewportSize(): {
		width: number;
		height: number;
	} | null;
	/**
	 * Playwright: page.setViewportSize({ width, height }).
	 */
	setViewportSize({ width, height }: {
		width: number;
		height: number;
	}): Promise<void>;
	url(): string;
	title(): Promise<unknown>;
	/**
	 * Synthetic: the page behaves as the focused, visible one (`document.hasFocus()`,
	 * an active lifecycle) while the user's tab and frontmost app stay as they are.
	 * Every page already does; this asserts it again. Reading, screenshots, and
	 * input never need it. `bringToFrontForUser()` is the visible operation.
	 */
	bringToFront(): Promise<void>;
	/**
	 * Switches the user's Chrome to this tab and brings its window in front of
	 * their other apps. Only when the user asked to see the page.
	 */
	bringToFrontForUser(): Promise<void>;
	screenshot(options?: {
		format?: string;
		quality?: number;
		clip?: {
			x: number;
			y: number;
			width: number;
			height: number;
		};
		fullPage?: boolean;
		scale?: number;
	}): Promise<Buffer>;
	pdf(options?: {
		printBackground?: boolean;
		landscape?: boolean;
		scale?: number;
		path?: string;
	}): Promise<Buffer<ArrayBuffer>>;
	close(): Promise<void>;
}

Download#

/**
 * Playwright-shaped Download object.
 * @see https://playwright.dev/docs/api/class-download
 */
class Download {
	page(): Page | null;
	url(): string;
	suggestedFilename(): string;
	path(): Promise<string>;
	saveAs(targetPath: string): Promise<void>;
	failure(): Promise<string | null>;
	/**
	 * Playwright: download.cancel(). No-op if already finished or canceled.
	 * @see https://playwright.dev/docs/api/class-download#download-cancel
	 */
	cancel(): Promise<void>;
	delete(): Promise<void>;
}

CDPSessionPublic#

/**
 * Playwright-shaped CDP session (page-scoped or browser-scoped).
 * @see https://playwright.dev/docs/api/class-cdpsession
 */
class CDPSessionPublic {
	send(method: string, params?: Record<string, unknown>): Promise<unknown>;
	on(event: string, handler: (params: Record<string, unknown>) => void): this;
	detach(): Promise<void>;
}

Mouse#

class Mouse {
	page: Page;
	move(x: number, y: number, options?: {
		steps?: number;
	}): Promise<void>;
	down(options?: {
		button?: string;
		clickCount?: number;
		modifiers?: string[];
	}): Promise<void>;
	up(options?: {
		button?: string;
		clickCount?: number;
		modifiers?: string[];
	}): Promise<void>;
	click(x: number, y: number, options?: {
		button?: string;
		clickCount?: number;
		delay?: number;
		modifiers?: string[];
	}): Promise<void>;
	dblclick(x: number, y: number, options?: {
		button?: string;
		delay?: number;
		modifiers?: string[];
	}): Promise<void>;
	wheel(deltaX: number, deltaY: number): Promise<void>;
}

Keyboard#

class Keyboard {
	page: Page;
	down(key: string): Promise<void>;
	up(key: string): Promise<void>;
	press(key: string, options?: {
		delay?: number;
	}): Promise<void>;
	insertText(text: unknown): Promise<void>;
	type(text: unknown, options?: {
		delay?: number;
	}): Promise<void>;
}

BrowserScreencast#

class BrowserScreencast {
	start(options: BrowserScreencastStartOptions): Promise<BrowserDisposable>;
	stop(): Promise<void>;
	showOverlay(html: string, options?: {
		duration?: number;
	}): Promise<BrowserDisposable>;
	showChapter(title: string, options?: {
		description?: string;
		duration?: number;
	}): Promise<void>;
	showActions(options?: ScreencastActionOptions): Promise<BrowserDisposable>;
	hideActions(): Promise<void>;
	showOverlays(): Promise<void>;
	hideOverlays(): Promise<void>;
}

FilterOptions#

interface FilterOptions {
	hasText?: string | RegExp;
	hasNotText?: string | RegExp;
	has?: Locator;
	hasNot?: Locator;
	visible?: boolean;
	exact?: boolean;
}

Locator#

class Locator {
	locator(selector: string, options?: FilterOptions): Locator;
	getByRole(role: string, options?: RoleOptions): Locator;
	getByText(text: string | RegExp, options?: {
		exact?: boolean;
	}): Locator;
	getByLabel(text: string | RegExp, options?: {
		exact?: boolean;
	}): Locator;
	getByPlaceholder(text: string | RegExp, options?: {
		exact?: boolean;
	}): Locator;
	getByTestId(testId: string | RegExp): Locator;
	getByAltText(text: string | RegExp, options?: {
		exact?: boolean;
	}): Locator;
	getByTitle(text: string | RegExp, options?: {
		exact?: boolean;
	}): Locator;
	frameLocator(frameSelector: string): Locator;
	filter(options?: FilterOptions): Locator;
	and(other: Locator): Locator;
	or(other: Locator): Locator;
	nth(index: number): Locator;
	first(): Locator;
	last(): Locator;
	/** Short label for errors and expect() messages. */
	toString(): string;
	count(): Promise<number>;
	all(): Promise<Locator[]>;
	allTextContents(options?: TimeoutOptions): Promise<string[]>;
	innerHTML(options?: TimeoutOptions): Promise<unknown>;
	selectText(options?: TimeoutOptions): Promise<void>;
	dispatchEvent(type: string, eventInit?: Record<string, unknown>, options?: TimeoutOptions): Promise<void>;
	drop(payload: DropPayload, options?: TimeoutOptions): Promise<void>;
	page(): Page;
	allInnerTexts(): Promise<string[]>;
	evaluateAll(pageFunction: (els: unknown[], arg?: unknown) => unknown, arg?: unknown): Promise<unknown>;
	ariaSnapshot(options?: TimeoutOptions): Promise<string>;
	isVisible(options?: TimeoutOptions): Promise<boolean>;
	isEnabled(options?: TimeoutOptions): Promise<boolean>;
	isDisabled(options?: TimeoutOptions): Promise<boolean>;
	isEditable(options?: TimeoutOptions): Promise<boolean>;
	isHidden(options?: TimeoutOptions): Promise<boolean>;
	isChecked(options?: TimeoutOptions): Promise<boolean>;
	innerText(options?: TimeoutOptions): Promise<string>;
	textContent(options?: TimeoutOptions): Promise<string | null>;
	inputValue(options?: TimeoutOptions): Promise<string>;
	getAttribute(name: string, options?: TimeoutOptions): Promise<string | null>;
	boundingBox(options?: TimeoutOptions): Promise<AgentRect>;
	waitFor(options?: TimeoutOptions): Promise<void>;
	evaluate(pageFunction: (el: unknown, arg?: unknown) => unknown, arg?: unknown, options?: TimeoutOptions): Promise<unknown>;
	click(options?: TimeoutOptions): Promise<void>;
	dblclick(options?: TimeoutOptions): Promise<void>;
	hover(options?: TimeoutOptions): Promise<void>;
	fill(value: unknown, options?: TimeoutOptions): Promise<void>;
	type(value: unknown, options?: TimeoutOptions): Promise<void>;
	press(value: string, options?: TimeoutOptions): Promise<void>;
	check(options?: TimeoutOptions): Promise<void>;
	uncheck(options?: TimeoutOptions): Promise<void>;
	setChecked(checked: boolean, options?: TimeoutOptions): Promise<void>;
	clear(options?: TimeoutOptions): Promise<void>;
	blur(options?: TimeoutOptions): Promise<void>;
	focus(options?: TimeoutOptions): Promise<void>;
	pressSequentially(value: unknown, options?: TimeoutOptions): Promise<void>;
	dragTo(target: Locator, options?: TimeoutOptions): Promise<void>;
	selectOption(value: unknown, options?: TimeoutOptions): Promise<string[]>;
	scrollIntoViewIfNeeded(options?: TimeoutOptions): Promise<void>;
	screenshot(options?: TimeoutOptions): Promise<Buffer<ArrayBufferLike>>;
	setInputFiles(files: string | string[], options?: TimeoutOptions): Promise<void>;
}

RoleOptions#

interface RoleOptions {
	name?: string | RegExp;
	exact?: boolean;
	checked?: boolean;
	pressed?: boolean;
	expanded?: boolean;
	selected?: boolean;
	disabled?: boolean;
	level?: number;
	includeHidden?: boolean;
}

TimeoutOptions#

interface TimeoutOptions {
	timeout?: number;
	strict?: boolean;
	force?: boolean;
	position?: {
		x: number;
		y: number;
	};
	state?: string;
	waitUntil?: string;
	predicate?: (payload: unknown) => boolean | Promise<boolean>;
	url?: unknown;
	button?: string;
	modifiers?: string[];
	clickCount?: number;
	delay?: number;
	delayMs?: number;
}

Response#

class Response {
	page: Page;
	url(): string;
	status(): number;
	statusText(): string;
	ok(): boolean;
	headers(): Record<string, string>;
	allHeaders(): Promise<Record<string, string>>;
	request(): Request;
	body(): Promise<Buffer<ArrayBufferLike>>;
	text(): Promise<string>;
	json(): Promise<any>;
}

RouteHandler#

type RouteHandler = (route: Route, request: RouteRequest) => unknown;

FrameHandle#

interface FrameHandle {
	url: () => string;
	name: () => string;
	parentFrame: () => FrameHandle | null;
	isMain: () => boolean;
}

RemoveAllListenersBehavior#

type RemoveAllListenersBehavior = "default" | "wait" | "ignoreErrors";

ConsoleMessage#

/**
 * Playwright-shaped console message.
 * @see https://playwright.dev/docs/api/class-consolemessage
 */
class ConsoleMessage {
	type(): string;
	text(): string;
	location(): {
		url?: string;
		lineNumber?: number;
		columnNumber?: number;
	};
	page(): Page;
}

BrowserScreencastStartOptions#

type BrowserScreencastStartOptions = ScreencastStartCommon & ({
	path: string;
	onFrame?: (frame: BrowserScreencastFrame) => unknown;
} | {
	path?: string;
	onFrame: (frame: BrowserScreencastFrame) => unknown;
});

BrowserDisposable#

interface BrowserDisposable {
	[Symbol.dispose](): void;
}

ScreencastActionOptions#

type ScreencastActionOptions = {
	cursor?: "none" | "pointer";
	duration?: number;
	fontSize?: number;
	position?: "top-left" | "top" | "top-right" | "bottom-left" | "bottom" | "bottom-right";
	style?: {
		point?: string;
		highlight?: string;
		title?: string;
	};
};

DropPayload#

interface DropPayload {
	files?: string | string[] | {
		name: string;
		mimeType: string;
		buffer: Buffer;
	} | Array<{
		name: string;
		mimeType: string;
		buffer: Buffer;
	}>;
	data?: Record<string, string>;
}

AgentRect#

interface AgentRect {
	x: number;
	y: number;
	width: number;
	height: number;
	visible?: boolean;
	enabled?: boolean;
	viewport?: {
		width: number;
		height: number;
	};
}

Request#

/**
 * Playwright-shaped request (thin).
 * @see https://playwright.dev/docs/api/class-request
 */
class Request {
	url(): string;
	method(): string;
	resourceType(): string;
	headers(): Record<string, string>;
	failure(): {
		errorText: string;
	} | null;
	frame(): null;
}

Route#

/** The handle a page.route(pattern, handler) handler receives. */
interface Route {
	request(): RouteRequest;
	abort(errorReason?: string): Promise<void>;
	continue(): Promise<void>;
}

RouteRequest#

/** The request a route handler sees. Thin, like what page.route passes. */
interface RouteRequest {
	url(): string;
	method(): string;
	headers(): Record<string, string>;
	resourceType(): string;
}

ScreencastStartCommon#

type ScreencastStartCommon = {
	fps?: number;
	quality?: number;
	size?: ScreencastSize;
};

BrowserScreencastFrame#

type BrowserScreencastFrame = {
	data: Buffer;
	timestamp: number;
	viewportWidth: number;
	viewportHeight: number;
};

ScreencastSize#

type ScreencastSize = {
	width: number;
	height: number;
};