Page
Page implements WebLocators directly, so every builder documented under Locator (getByRole, getByText, ...) is also callable straight on page. Page.locator(selector) returns a Locator scoped to a raw selector.
click
Clicks the first element matching selector.
public synchronized ClickResult click(String selector)
public synchronized ClickResult click(String selector, CommandOptions options)fill
Sets an input/textarea's value.
public synchronized FillResult fill(String selector, String value)
public synchronized FillResult fill(String selector, String value, CommandOptions options)hover
Hovers the pointer over the matching element.
public synchronized ElementResult hover(String selector)
public synchronized ElementResult hover(String selector, CommandOptions options)press
Sends a key press to the matching element, optionally typing PressOptions.text() in the same call.
public synchronized PressResult press(String selector, String key)
public synchronized PressResult press(String selector, String key, PressOptions options)focus
Focuses the matching element.
public synchronized ElementResult focus(String selector)
public synchronized ElementResult focus(String selector, CommandOptions options)highlight
Visually highlights matching elements for a duration — a debugging aid.
public synchronized HighlightResult highlight(String selector)
public synchronized HighlightResult highlight(String selector, HighlightOptions options)count
Returns how many elements match selector.
public synchronized CountResult count(String selector)
public synchronized CountResult count(String selector, CommandOptions options)textContent / innerText
Reads the raw textContent, or the rendered innerText, of the matching element.
public synchronized TextResult textContent(String selector)
public synchronized TextResult innerText(String selector)waitForSelector
Waits, retrying, until selector matches — optionally requiring visibility.
public synchronized WaitForSelectorResult waitForSelector(String selector)
public synchronized WaitForSelectorResult waitForSelector(String selector, WaitForSelectorOptions options)Example
page.waitForSelector("xpath=//h1[text()=\"Form Inputs\"]");screenshot
Captures a PNG screenshot; options.fullPage() captures the whole scrollable page, and options.path() writes the PNG to disk.
public synchronized ScreenshotResult screenshot()
public synchronized ScreenshotResult screenshot(ScreenshotOptions options)accessibilitySnapshot
Captures the accessibility tree as JSON or YAML text; options controls format and mode (default/ai/autoexpect/codegen).
public synchronized String accessibilitySnapshot()
public synchronized String accessibilitySnapshot(AccessibilitySnapshotOptions options)locator
Builds a Locator bound to this page for a raw CSS/XPath/aw= selector.
public Locator locator(String selector)registerHook
Arms a lifecycle hook before the action that triggers it.
public synchronized <T> Hook<T> registerHook(HookType<T> type)