allwright

API ReferenceGoPage

Page

Page is an alias for Tab (type Page = Tab) — navigation and every action/query below. Locator() returns a Locator scoped to a selector, which exposes the same action methods plus the semantic builders and filters documented under Locator.

Click

MethodSince v0.0.14

Clicks the first matching element. CommandOptions accepts MouseButtonLeft, MouseButtonMiddle, or MouseButtonRight and a ClickCount from 1 to 3 for click calls.

func (t *Tab) Click(ctx context.Context, cssSelector string, options ...CommandOptions) error

Example

page.Click(ctx, "button#submit")

DblClick

MethodSince v0.1.25

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

func (t *Tab) DblClick(ctx context.Context, cssSelector string, options ...CommandOptions) error

Fill

MethodSince v0.0.14

Sets a form field's value.

func (t *Tab) Fill(ctx context.Context, cssSelector string, value string, options ...CommandOptions) error

Example

page.Fill(ctx, "#email", "user@example.com")

Hover

MethodSince v0.0.14

Hovers the pointer over the matching element.

func (t *Tab) Hover(ctx context.Context, cssSelector string, options ...CommandOptions) error

Press

MethodSince v0.0.14

Sends a key press to the matching element; PressOptions.Text can type literal text in the same call.

func (t *Tab) Press(ctx context.Context, cssSelector string, key string, options ...PressOptions) error

Focus

MethodSince v0.0.14

Focuses the matching element.

func (t *Tab) Focus(ctx context.Context, cssSelector string, options ...CommandOptions) error

Highlight

MethodSince v0.0.14

Visually highlights matching elements for a duration — a debugging aid, not an assertion.

func (t *Tab) Highlight(ctx context.Context, cssSelector string, options ...HighlightOptions) error

Count

MethodSince v0.0.14

Returns how many elements match the selector.

func (t *Tab) Count(ctx context.Context, cssSelector string, options ...CommandOptions) (int, error)

TextContent / InnerText

MethodSince v0.0.14

Reads the element's full DOM text content, or its rendered inner text, respectively.

func (t *Tab) TextContent(ctx context.Context, cssSelector string, options ...CommandOptions) (string, error)
func (t *Tab) InnerText(ctx context.Context, cssSelector string, options ...CommandOptions) (string, error)

Example

heading, err := page.TextContent(ctx, "h1")

URL

MethodSince v0.1.14

Reads the page's current URL — for a frame page, the frame document's URL.

func (t *Tab) URL(ctx context.Context, options ...CommandOptions) (string, error)

Example

current, err := page.URL(ctx)

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 — nil with no error when it's missing, a pointer to "" when it's present but empty. A missing element or an incompatible control returns an error.

func (t *Tab) InputValue(ctx context.Context, selector string, options ...CommandOptions) (string, error)
func (t *Tab) IsChecked(ctx context.Context, selector string, options ...CommandOptions) (bool, error)
func (t *Tab) GetAttribute(ctx context.Context, selector string, name string, options ...CommandOptions) (*string, error)

Example

value, err := page.Locator("input[name=email]").InputValue(ctx)
checked, err := page.Locator("input[type=checkbox]").IsChecked(ctx)
href, err := page.Locator("a").GetAttribute(ctx, "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 — a pointer to "" for a bare caret, nil for input types that don't support selection.

func (t *Tab) SelectedOptions(ctx context.Context, selector string, options ...CommandOptions) ([]CapturedOption, error)
func (t *Tab) SelectedText(ctx context.Context, selector string, options ...CommandOptions) (*string, error)

type CapturedOption struct { Value string; Label string; Index uint32 }

BoundingBox

MethodSince v0.1.14

Reads the first match's box in CSS pixels, relative to the page or frame viewport. Returns nil with no error for a hidden or zero-area element.

func (t *Tab) BoundingBox(ctx context.Context, selector string, options ...CommandOptions) (*BoundingBox, error)

type BoundingBox struct { X, Y, Width, Height float64 }

WaitForSelector

MethodSince v0.0.14

Waits, retrying, until an element matching the selector appears — optionally requiring it to be visible via WaitForSelectorOptions.Visible.

func (t *Tab) WaitForSelector(ctx context.Context, cssSelector string, options ...WaitForSelectorOptions) error

Screenshot

MethodSince v0.0.54 – v0.0.55

Captures a PNG screenshot of the page. ScreenshotOptions.FullPage captures the whole scrollable page; ScreenshotOptions.Path writes the PNG straight to disk.

func (t *Tab) Screenshot(ctx context.Context, options ...ScreenshotOptions) ([]byte, error)

AccessibilitySnapshot

MethodSince v0.1.1

Captures the accessibility tree as a JSON or YAML string. AccessibilitySnapshotOptions.Mode selects default, ai (stable aria-ref per node), autoexpect, or codegen.

func (t *Tab) AccessibilitySnapshot(ctx context.Context, options ...AccessibilitySnapshotOptions) (string, error)

Example

tree, err := page.AccessibilitySnapshot(ctx, allwright.AccessibilitySnapshotOptions{Mode: "ai"})

Locator

MethodSince v0.0.33

Builds a Locator bound to this page for a raw CSS/XPath selector, or use the GetBy* semantic builders documented under Locator.

func (t *Tab) Locator(selector string) *Locator

RegisterHook

FunctionSince v0.1.5

Registers a lifecycle hook on a page before the action that triggers it. A package-level generic function, not a method — Go doesn't support generic methods.

func RegisterHook[T any](ctx context.Context, page *Page, hookType HookType[T]) (*Hook[T], error)