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 synchronized NavigateResult goTo(String url)
public synchronized NavigateResult goTo(String url, CommandOptions options)

Example

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

click

MethodSince v0.0.14

Clicks the first element matching selector.

public synchronized ClickResult click(String selector)
public synchronized ClickResult click(String selector, CommandOptions options)

fill

MethodSince v0.0.14

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

MethodSince v0.0.14

Hovers the pointer over the matching element.

public synchronized ElementResult hover(String selector)
public synchronized ElementResult 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 synchronized PressResult press(String selector, String key)
public synchronized PressResult press(String selector, String key, PressOptions options)

focus

MethodSince v0.0.14

Focuses the matching element.

public synchronized ElementResult focus(String selector)
public synchronized ElementResult focus(String selector, CommandOptions options)

highlight

MethodSince v0.0.14

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

MethodSince v0.0.14

Returns how many elements match selector.

public synchronized CountResult count(String selector)
public synchronized CountResult count(String selector, CommandOptions options)

textContent / innerText

MethodSince v0.0.14

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

MethodSince v0.0.14

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

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 synchronized ScreenshotResult screenshot()
public synchronized ScreenshotResult 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)