allwright

API ReferenceTypeScriptPage

Page

Page.locator(selector) returns a Locator scoped to a selector; every getByRole/getByText/etc. builder documented under Locator is also callable straight on page.

goto

MethodSince v0.0.14

Navigates the page to a URL. navigate() is an alias.

goto(url: string, options?: CommandOptions): Promise<void>

Example

await page.goto("https://themoderninternet.vercel.app");

click

MethodSince v0.0.14

Clicks the first matching element. ClickOptions accepts left, middle, or right button and a clickCount from 1 to 3.

click(selector: string, options?: ClickOptions): Promise<void>

dblclick

MethodSince v0.1.25

Double-clicks the first matching element with the selected mouse button.

dblclick(selector: string, options?: Omit<ClickOptions, 'clickCount'>): Promise<void>

fill

MethodSince v0.0.14

Sets an input's value.

fill(selector: string, value: string, options?: CommandOptions): Promise<void>

Example

await page.fill('input[name=email]', 'you@example.com');

hover

MethodSince v0.0.14

Hovers the pointer over the matching element.

hover(selector: string, options?: CommandOptions): Promise<void>

press

MethodSince v0.0.14

Sends a key press to the matching element, optionally typing PressOptions.text in the same call.

press(selector: string, key: string, options?: PressOptions): Promise<void>

focus

MethodSince v0.0.14

Focuses the matching element.

focus(selector: string, options?: CommandOptions): Promise<void>

highlight

MethodSince v0.0.14

Visually highlights matching elements for a duration — a debugging aid, not an assertion.

highlight(selector: string, options?: HighlightOptions): Promise<void>

count

MethodSince v0.0.14

Returns how many elements match selector.

count(selector: string, options?: CommandOptions): Promise<number>

textContent / innerText

MethodSince v0.0.14

Reads the element's raw textContent, or its rendered innerText.

textContent(selector: string, options?: CommandOptions): Promise<string | null>
innerText(selector: string, options?: CommandOptions): Promise<string>

url

MethodSince v0.1.14

Reads the page's current URL — for a frame page, the frame document's URL.

url(options?: CommandOptions): Promise<string>

Example

const url = await page.url();

inputValue / isChecked / getAttribute

MethodSince v0.1.14

Read the first match's state: the live value of an input, textarea, or select; the checked state of a native or ARIA checkbox/radio (ARIA mixed reads as false); or an attribute — null when it's missing, "" when it's present but empty. A missing element or an incompatible control raises an error.

inputValue(selector: string, options?: CommandOptions): Promise<string>
isChecked(selector: string, options?: CommandOptions): Promise<boolean>
getAttribute(selector: string, name: string, options?: CommandOptions): Promise<string | null>

Example

const value = await page.locator('input[name=email]').inputValue();
const checked = await page.locator('input[type=checkbox]').isChecked();
const href = await page.locator('a').getAttribute('href');

selectedOptions / selectedText

MethodSince v0.1.14

selectedOptions reads a native select (including multiple selection) or an ARIA listbox/combobox's aria-selected="true" options. selectedText reads the textbox's selected substring — "" for a bare caret, null for input types that don't support selection.

selectedOptions(selector: string, options?: CommandOptions): Promise<CapturedOption[]>
selectedText(selector: string, options?: CommandOptions): Promise<string | null>

interface CapturedOption { value: string; label: string; index: number }

Example

const [first] = await page.locator('select').selectedOptions(); // { value, label, index }

boundingBox

MethodSince v0.1.14

Reads the first match's box in CSS pixels, relative to the page or frame viewport. Returns null for a hidden or zero-area element.

boundingBox(selector: string, options?: CommandOptions): Promise<BoundingBox | null>

interface BoundingBox { x: number; y: number; width: number; height: number }

Example

const box = await page.locator('button').boundingBox();

waitForSelector

MethodSince v0.0.14

Waits, retrying, until selector matches — optionally requiring visible: true.

waitForSelector(selector: string, options?: WaitForSelectorOptions): Promise<void>

screenshot

MethodSince v0.0.54 – v0.0.55

Captures a PNG screenshot; options.fullPage captures the whole scrollable page, and options.path writes the PNG to disk.

screenshot(options?: ScreenshotOptions): Promise<Uint8Array>

accessibilitySnapshot

MethodSince v0.1.1

Captures the accessibility tree as JSON or YAML text; options.mode selects "default", "ai" (stable per-node reference), "autoexpect", or "codegen".

accessibilitySnapshot(options?: AccessibilitySnapshotOptions): Promise<string>

Example

const tree = JSON.parse(await page.accessibilitySnapshot({ mode: "ai" }));

locator

MethodSince v0.0.33

Builds a Locator scoped to this page for a CSS/XPath/aw= selector, or use the getBy* semantic builders documented under Locator.

locator(selector: string, options?: LocatorFilterOptions): Locator

registerHook

MethodSince v0.1.5

Registers a lifecycle hook before the action that triggers it.

registerHook<T>(type: HookType<T>): Promise<Hook<T>>

frame

MethodSince v0.1.13

Resolves the single iframe matching selector to a Page once its document has loaded and settled. Same as page.locator(selector).frame(options) — see Locator.frame.

frame(selector: string, options?: CommandOptions): Promise<Page>