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
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
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
Double-clicks the first matching element with the selected mouse button.
dblclick(selector: string, options?: Omit<ClickOptions, 'clickCount'>): Promise<void>fill
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
Hovers the pointer over the matching element.
hover(selector: string, options?: CommandOptions): Promise<void>press
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
Focuses the matching element.
focus(selector: string, options?: CommandOptions): Promise<void>highlight
Visually highlights matching elements for a duration — a debugging aid, not an assertion.
highlight(selector: string, options?: HighlightOptions): Promise<void>count
Returns how many elements match selector.
count(selector: string, options?: CommandOptions): Promise<number>textContent / innerText
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
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
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
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
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
Waits, retrying, until selector matches — optionally requiring visible: true.
waitForSelector(selector: string, options?: WaitForSelectorOptions): Promise<void>screenshot
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
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
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): LocatorregisterHook
Registers a lifecycle hook before the action that triggers it.
registerHook<T>(type: HookType<T>): Promise<Hook<T>>frame
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>