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 matching element. ClickOptions accepts LEFT, MIDDLE, or RIGHT and a click count from 1 to 3.
public void click(String selector)
public void click(String selector, CommandOptions options)
public void click(String selector, ClickOptions options)dblclick
Double-clicks the first matching element with the selected mouse button.
public void dblclick(String selector)
public void dblclick(String selector, ClickOptions options)fill
Sets an input/textarea's value.
public void fill(String selector, String value)
public void fill(String selector, String value, CommandOptions options)hover
Hovers the pointer over the matching element.
public void hover(String selector)
public void hover(String selector, CommandOptions options)press
Sends a key press to the matching element, optionally typing PressOptions.text() in the same call.
public void press(String selector, String key)
public void press(String selector, String key, PressOptions options)focus
Focuses the matching element.
public void focus(String selector)
public void focus(String selector, CommandOptions options)highlight
Visually highlights matching elements for a duration — a debugging aid.
public void highlight(String selector)
public void highlight(String selector, HighlightOptions options)count
Returns how many elements match selector.
public int count(String selector)
public int count(String selector, CommandOptions options)textContent / innerText
Reads the raw textContent, or the rendered innerText, of the matching element.
public String textContent(String selector)
public String innerText(String selector)url
Reads the page's current URL — for a frame page, the frame document's URL.
public synchronized String url()
public synchronized String url(CommandOptions options)Example
String current = 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. Each has a CommandOptions overload; a missing element or an incompatible control throws AllwrightException.
public synchronized String inputValue(String selector)
public synchronized boolean isChecked(String selector)
public synchronized String getAttribute(String selector, String name)Example
String value = page.locator("input[name=email]").inputValue();
boolean checked = page.locator("input[type=checkbox]").isChecked();
String href = 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.
public synchronized List<CapturedOption> selectedOptions(String selector)
public synchronized String selectedText(String selector)
public record CapturedOption(String value, String label, int 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.
public synchronized BoundingBox boundingBox(String selector)
public record BoundingBox(double x, double y, double width, double height) {}waitForSelector
Waits, retrying, until selector matches — optionally requiring visibility.
public void waitForSelector(String selector)
public void 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 byte[] screenshot()
public byte[] 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)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.
public synchronized Page frame(String selector, CommandOptions options)