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 element matching the selector.

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

Example

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

Fill

MethodSince v0.0.14

Sets a form field's value.

func (t *Tab) Fill(ctx context.Context, cssSelector string, value string, options ...CommandOptions) (*FillResult, 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) (*ElementResult, 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) (*PressResult, error)

Focus

MethodSince v0.0.14

Focuses the matching element.

func (t *Tab) Focus(ctx context.Context, cssSelector string, options ...CommandOptions) (*ElementResult, 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) (*HighlightResult, error)

Count

MethodSince v0.0.14

Returns how many elements match the selector.

func (t *Tab) Count(ctx context.Context, cssSelector string, options ...CommandOptions) (*CountResult, 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) (*TextResult, error)
func (t *Tab) InnerText(ctx context.Context, cssSelector string, options ...CommandOptions) (*TextResult, error)

Example

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

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) (*WaitForSelectorResult, 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) (*ScreenshotResult, 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)