Skip to main content
Version: Next

StagehandPage

A Playwright Page enhanced with Stagehand AI methods.

Wraps a Playwright Page and an AsyncSession, proxying all standard Playwright methods transparently while adding act(), extract(), observe(), and execute() AI operations bound to the current page.

Index

Methods

__getattr__

  • __getattr__(name): Any
  • Parameters

    • name: str

    Returns Any

__init__

  • __init__(page, session): None
  • Parameters

    • page: Page
    • session: AsyncSession

    Returns None

act

  • async act(): SessionActResponse
  • Perform an action on the page using natural language. Argument page is automatically set.


    Returns SessionActResponse

    The action result from Stagehand.

execute

  • async execute(): SessionExecuteResponse
  • Run an autonomous multi-step AI agent on the page. Argument page is automatically set.


    Returns SessionExecuteResponse

    The result of the agent execution.

extract

  • async extract(): SessionExtractResponse
  • Extract structured data from the page using natural language. Argument page is automatically set.


    Returns SessionExtractResponse

    Extracted data matching the requested schema.

observe

  • async observe(): SessionObserveResponse
  • Observe the page and get AI-suggested actions. Argument page is automatically set.


    Returns SessionObserveResponse

    Observation result with suggested actions.

Properties

stagehand_session

stagehand_session: AsyncSession

Provides access to the underlying Stagehand session.