allwright

API ReferenceRustPage

Page

Page is Tab under a type alias. Every action here also has a *_with_options twin (e.g. click_with_options) that accepts the same call plus a typed Options struct — shown once here, favoring the fuller signature. Tab::locator(...) and the get_by_* builders under Locator are also implemented directly on Tab.

click

MethodSince v0.0.14

Clicks the first matching element. ClickOptions accepts Left, Middle, or Right and a click_count from 1 to 3; CommandOptions remains accepted for compatibility.

pub async fn click_with_options(&self, css_selector: impl Into<String>, options: impl Into<ClickOptions>) -> Result<()>

Example

page.click("a[target=_blank]").await?;

dblclick

MethodSince v0.1.25

Double-clicks the first matching element; dblclick(...) uses default options.

pub async fn dblclick_with_options(&self, css_selector: impl Into<String>, options: ClickOptions) -> Result<()>

fill

MethodSince v0.0.14

Sets an input/textarea's value; fill(...) omits options for the default timeout.

pub async fn fill_with_options(&self, css_selector: impl Into<String>, value: impl Into<String>, options: CommandOptions) -> Result<()>

hover

MethodSince v0.0.14

Hovers the pointer over the matching element; hover(...) omits options for the default timeout.

pub async fn hover_with_options(&self, css_selector: impl Into<String>, options: CommandOptions) -> Result<()>

press

MethodSince v0.0.14

Sends a key press to the matching element, optionally typing PressOptions.text; press(...) omits options.

pub async fn press_with_options(&self, css_selector: impl Into<String>, key: impl Into<String>, options: PressOptions) -> Result<()>

focus

MethodSince v0.0.14

Focuses the matching element; focus(...) omits options for the default timeout.

pub async fn focus_with_options(&self, css_selector: impl Into<String>, options: CommandOptions) -> Result<()>

highlight

MethodSince v0.0.14

Visually highlights matching elements for a duration — a debugging aid; highlight(...) omits options.

pub async fn highlight_with_options(&self, css_selector: impl Into<String>, options: HighlightOptions) -> Result<()>

count

MethodSince v0.0.14

Returns how many elements match the selector; count(...) omits options for the default timeout.

pub async fn count_with_options(&self, css_selector: impl Into<String>, options: CommandOptions) -> Result<u32>

text_content / inner_text

MethodSince v0.0.14

Reads the raw textContent, or (via inner_text) the rendered innerText, of the matching element.

pub async fn text_content_with_options(&self, css_selector: impl Into<String>, options: CommandOptions) -> Result<Option<String>>
pub async fn inner_text_with_options(&self, css_selector: impl Into<String>, options: CommandOptions) -> Result<String>

Example

page.text_content(selector).await?;

url

MethodSince v0.1.14

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

pub async fn url(&self) -> Result<String>
pub async fn url_with_options(&self, options: CommandOptions) -> Result<String>

Example

let current = page.url().await?;

input_value / is_checked / get_attribute

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 — None when it's missing, Some("") when it's present but empty. Each has a _with_options variant; a missing element or an incompatible control returns Err.

pub async fn input_value(&self, selector: impl Into<String>) -> Result<String>
pub async fn is_checked(&self, selector: impl Into<String>) -> Result<bool>
pub async fn get_attribute(&self, selector: impl Into<String>, name: impl Into<String>) -> Result<Option<String>>

Example

let value = page.locator("input[name=email]").input_value().await?;
let checked = page.locator("input[type=checkbox]").is_checked().await?;
let href = page.locator("a").get_attribute("href").await?;

selected_options / selected_text

MethodSince v0.1.14

selected_options reads a native select (including multiple selection) or an ARIA listbox/combobox's aria-selected="true" options. selected_text reads the textbox's selected substring — Some("") for a bare caret, None for input types that don't support selection.

pub async fn selected_options(&self, selector: impl Into<String>) -> Result<Vec<CapturedOption>>
pub async fn selected_text(&self, selector: impl Into<String>) -> Result<Option<String>>

pub struct CapturedOption { pub value: String, pub label: String, pub index: u32 }

bounding_box

MethodSince v0.1.14

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

pub async fn bounding_box(&self, selector: impl Into<String>) -> Result<Option<BoundingBox>>

pub struct BoundingBox { pub x: f64, pub y: f64, pub width: f64, pub height: f64 }

wait_for_selector

MethodSince v0.0.14

Waits, retrying, until the selector matches — WaitForSelectorOptions.visible optionally requires visibility.

pub async fn wait_for_selector_with_options(&self, css_selector: impl Into<String>, options: WaitForSelectorOptions) -> Result<()>

Example

page.wait_for_selector_with_options(selector, WaitForSelectorOptions { visible: Some(true), timeout_ms: Some(10_000) }).await?;

screenshot

MethodSince v0.0.54 – v0.0.55

Captures a PNG screenshot; ScreenshotOptions.full_page captures the whole scrollable page, and .path writes the PNG to disk.

pub async fn screenshot_with_options(&self, options: ScreenshotOptions) -> Result<Vec<u8>>

accessibility_snapshot

MethodSince v0.1.1

Captures the accessibility tree as JSON or YAML text; AccessibilitySnapshotOptions.mode selects Default, Ai (stable aria-ref per node), Autoexpect, or Codegen.

pub async fn accessibility_snapshot_with_options(&self, options: AccessibilitySnapshotOptions) -> Result<String>

locator

MethodSince v0.0.33

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

pub fn locator(&self, css_selector: impl Into<String>) -> Locator

register_hook

MethodSince v0.1.5

Registers a lifecycle hook before the action that triggers it. HookType is sealed — only the provided NEW_PAGE/FILE_CHOOSER/DOWNLOAD tags implement it.

pub async fn register_hook<T: HookType>(&self, hook_type: T) -> Result<Hook<T>>

frame_with_options

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_with_options(options) — see Locator::frame.

pub async fn frame_with_options(&self, selector: impl Into<String>, options: CommandOptions) -> Result<Tab>