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
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
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
Hovers the pointer over the matching element.
func (t *Tab) Hover(ctx context.Context, cssSelector string, options ...CommandOptions) (*ElementResult, error)Press
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
Focuses the matching element.
func (t *Tab) Focus(ctx context.Context, cssSelector string, options ...CommandOptions) (*ElementResult, error)Highlight
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
Returns how many elements match the selector.
func (t *Tab) Count(ctx context.Context, cssSelector string, options ...CommandOptions) (*CountResult, error)TextContent / InnerText
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
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
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
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
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) *LocatorRegisterHook
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)