Skip to content

Page

Abstract base class for browser page management.

Properties

url

url: str

Get current page URL.

Methods

async def navigate(url: str) -> None

Navigate to a URL.

select()

async def select(selector: str) -> List[Element]

Select all elements matching the selector.

Parameters: - selector - CSS selector or XPath string

Returns: List of Elements (may be empty)

select_one()

async def select_one(selector: str) -> Element

Select a single element matching the selector.

Parameters: - selector - CSS selector or XPath string

Raises: ValueError if no elements match or multiple elements match

wait_for_load()

async def wait_for_load(timeout: float = 10.0) -> None

Wait for page to fully load.

Parameters: - timeout - Maximum time to wait in seconds (default: 10.0)

screenshot()

async def screenshot(
    path: Optional[str] = None,
    full_page: bool = False
) -> bytes

Take a screenshot of the current page.

Parameters: - path - Optional file path to save screenshot - full_page - Screenshot the full scrollable page (default: False)

Returns: Screenshot as bytes (PNG format)

keyboard_type()

async def keyboard_type(
    text: str,
    clear: bool = False,
    delay: float = 0.05
) -> None

Type text using keyboard into the currently focused element.

Parameters: - text - Text to type - clear - Clear existing text before typing (default: False) - delay - Delay between keystrokes in seconds (default: 0.05)

evaluate()

async def evaluate(script: str) -> Any

Execute JavaScript in the page context.

Parameters: - script - JavaScript code to execute

Returns: Result of the script execution (JSON-serializable values)

get_cdp_dom_snapshot()

async def get_cdp_dom_snapshot() -> Dict[str, Any]

Get a CDP DOM snapshot of the current page.

Returns: CDP DOM snapshot data

get_cdp_accessibility_tree()

async def get_cdp_accessibility_tree() -> Dict[str, Any]

Get a CDP accessibility tree of the current page.

Returns: CDP accessibility tree data

close()

async def close() -> None

Close the page.