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<NavigateResult>

Example

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

click

MethodSince v0.0.14

Clicks the first element matching selector.

click(selector: string, options?: CommandOptions): Promise<ClickResult>

fill

MethodSince v0.0.14

Sets an input's value.

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

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<ElementResult>

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<PressResult>

focus

MethodSince v0.0.14

Focuses the matching element.

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

highlight

MethodSince v0.0.14

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

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

count

MethodSince v0.0.14

Returns how many elements match selector.

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

textContent / innerText

MethodSince v0.0.14

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

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

waitForSelector

MethodSince v0.0.14

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

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

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<ScreenshotResult>

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>>