allwright

API ReferenceJavaPage

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.

goTo / navigate

MethodSince v0.0.14

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

public void goTo(String url)
public void goTo(String url, CommandOptions options)

Example

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

click

MethodSince v0.0.14

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

MethodSince v0.1.25

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

public void dblclick(String selector)
public void dblclick(String selector, ClickOptions options)

fill

MethodSince v0.0.14

Sets an input/textarea's value.

public void fill(String selector, String value)
public void fill(String selector, String value, CommandOptions options)

hover

MethodSince v0.0.14

Hovers the pointer over the matching element.

public void hover(String selector)
public void hover(String selector, CommandOptions options)

press

MethodSince v0.0.14

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

MethodSince v0.0.14

Focuses the matching element.

public void focus(String selector)
public void focus(String selector, CommandOptions options)

highlight

MethodSince v0.0.14

Visually highlights matching elements for a duration — a debugging aid.

public void highlight(String selector)
public void highlight(String selector, HighlightOptions options)

count

MethodSince v0.0.14

Returns how many elements match selector.

public int count(String selector)
public int count(String selector, CommandOptions options)

textContent / innerText

MethodSince v0.0.14

Reads the raw textContent, or the rendered innerText, of the matching element.

public String textContent(String selector)
public String innerText(String selector)

url

MethodSince v0.1.14

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

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

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.

public synchronized List<CapturedOption> selectedOptions(String selector)
public synchronized String selectedText(String selector)

public record CapturedOption(String value, String label, int 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.

public synchronized BoundingBox boundingBox(String selector)

public record BoundingBox(double x, double y, double width, double height) {}

waitForSelector

MethodSince v0.0.14

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

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.

public byte[] screenshot()
public byte[] screenshot(ScreenshotOptions options)

accessibilitySnapshot

MethodSince v0.1.1

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

MethodSince v0.0.33

Builds a Locator bound to this page for a raw CSS/XPath/aw= selector.

public Locator locator(String selector)

registerHook

MethodSince v0.1.5

Arms a lifecycle hook before the action that triggers it.

public synchronized <T> Hook<T> registerHook(HookType<T> type)

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.

public synchronized Page frame(String selector, CommandOptions options)