> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stagehand.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# page

> Navigate, inspect, and interact with a browser page

A `Page` combines deterministic browser controls with Stagehand's natural-language `act`, `observe`, and `extract` methods. Navigation methods return the main-document [`Response`](/v4/reference/response), when the navigation produces one.

<Tabs>
  <Tab title="TypeScript">
    ## Quick start

    ```typescript theme={null}
    const page = await browser.context.newPage();
    const response = await page.goto("https://example.com");
    ```

    ## goto()

    Navigate the page to a URL.

    ```typescript theme={null}
    const response = await page.goto("https://example.com");
    ```

    <ParamField path="url" type="string">
      The destination URL.
    </ParamField>

    <ParamField path="options" type="PageNavigationOptions" optional>
      Options that configure this operation.

      <ParamField path="options.timeout" type="number" optional>
        Maximum wait time in milliseconds.
      </ParamField>

      <ParamField path="options.waitUntil" type="LoadState" optional>
        The target load state: `"load"`, `"domcontentloaded"`, or `"networkidle"`. Defaults to
        `"domcontentloaded"`.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="Promise<Response | null>">
      The final main-document response, or `null` when no network response was produced.
    </ResponseField>

    ## reload()

    Reload the current page.

    ```typescript theme={null}
    await page.reload();
    ```

    <ParamField path="options" type="PageReloadOptions" optional>
      Options that configure this operation.

      <ParamField path="options.ignoreCache" type="boolean" optional>
        Whether to bypass the browser cache.
      </ParamField>

      <ParamField path="options.timeout" type="number" optional>
        Maximum wait time in milliseconds.
      </ParamField>

      <ParamField path="options.waitUntil" type="LoadState" optional>
        The target load state: `"load"`, `"domcontentloaded"`, or `"networkidle"`. Defaults to
        `"domcontentloaded"`.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="Promise<Response | null>">
      The final main-document response, or `null` when no network response was produced.
    </ResponseField>

    ## goBack()

    Navigate backward in the page history.

    ```typescript theme={null}
    await page.goBack();
    ```

    <ParamField path="options" type="PageNavigationOptions" optional>
      Options that configure this operation.

      <ParamField path="options.timeout" type="number" optional>
        Maximum wait time in milliseconds.
      </ParamField>

      <ParamField path="options.waitUntil" type="LoadState" optional>
        The target load state: `"load"`, `"domcontentloaded"`, or `"networkidle"`. Defaults to
        `"domcontentloaded"`.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="Promise<Response | null>">
      The final main-document response, or `null` when no history navigation occurred or no network response was produced.
    </ResponseField>

    ## goForward()

    Navigate forward in the page history.

    ```typescript theme={null}
    await page.goForward();
    ```

    <ParamField path="options" type="PageNavigationOptions" optional>
      Options that configure this operation.

      <ParamField path="options.timeout" type="number" optional>
        Maximum wait time in milliseconds.
      </ParamField>

      <ParamField path="options.waitUntil" type="LoadState" optional>
        The target load state: `"load"`, `"domcontentloaded"`, or `"networkidle"`. Defaults to
        `"domcontentloaded"`.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="Promise<Response | null>">
      The final main-document response, or `null` when no history navigation occurred or no network response was produced.
    </ResponseField>

    ## click()

    Click at page coordinates.

    ```typescript theme={null}
    await page.click(240, 320);
    ```

    <ParamField path="x" type="number">
      The horizontal page coordinate.
    </ParamField>

    <ParamField path="y" type="number">
      The vertical page coordinate.
    </ParamField>

    <ParamField path="options" type="PageClickOptions" optional>
      Options that configure this operation.

      <ParamField path="options.button" type="MouseButton" optional>
        The mouse button to use: `"left"`, `"middle"`, or `"right"`.
      </ParamField>

      <ParamField path="options.clickCount" type="number" optional>
        The number of clicks to dispatch.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="Promise<void>">
      Resolves after the operation completes.
    </ResponseField>

    ## hover()

    Move the pointer to page coordinates.

    ```typescript theme={null}
    await page.hover(240, 320);
    ```

    <ParamField path="x" type="number">
      The horizontal page coordinate.
    </ParamField>

    <ParamField path="y" type="number">
      The vertical page coordinate.
    </ParamField>

    <ResponseField name="result" type="Promise<void>">
      Resolves after the operation completes.
    </ResponseField>

    ## scroll()

    Scroll from page coordinates by the supplied deltas.

    ```typescript theme={null}
    await page.scroll(240, 320, 0, 600);
    ```

    <ParamField path="x" type="number">
      The horizontal page coordinate.
    </ParamField>

    <ParamField path="y" type="number">
      The vertical page coordinate.
    </ParamField>

    <ParamField path="deltaX" type="number">
      Horizontal scroll distance.
    </ParamField>

    <ParamField path="deltaY" type="number">
      Vertical scroll distance.
    </ParamField>

    <ResponseField name="result" type="Promise<void>">
      Resolves after the operation completes.
    </ResponseField>

    ## dragAndDrop()

    Drag from one page coordinate to another.

    ```typescript theme={null}
    await page.dragAndDrop(100, 100, 400, 400);
    ```

    <ParamField path="fromX" type="number">
      The drag origin's horizontal coordinate.
    </ParamField>

    <ParamField path="fromY" type="number">
      The drag origin's vertical coordinate.
    </ParamField>

    <ParamField path="toX" type="number">
      The drop target's horizontal coordinate.
    </ParamField>

    <ParamField path="toY" type="number">
      The drop target's vertical coordinate.
    </ParamField>

    <ParamField path="options" type="PageDragAndDropOptions" optional>
      Options that configure this operation.

      <ParamField path="options.button" type="MouseButton" optional>
        The mouse button to use: `"left"`, `"middle"`, or `"right"`.
      </ParamField>

      <ParamField path="options.delay" type="number" optional>
        The input delay in milliseconds.
      </ParamField>

      <ParamField path="options.steps" type="number" optional>
        The number of intermediate pointer moves.
      </ParamField>

      <ParamField path="options.route" type="PageDragAndDropRoutePoint[]" optional>
        An ordered mouse route to follow instead of generating linear intermediate moves. The explicit
        `toX` and `toY` coordinates remain the final point.

        <ParamField path="options.route.x" type="number">
          A route point's horizontal coordinate.
        </ParamField>

        <ParamField path="options.route.y" type="number">
          A route point's vertical coordinate.
        </ParamField>
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="Promise<void>">
      Resolves after the operation completes.
    </ResponseField>

    ## type()

    Type text at the current input target.

    ```typescript theme={null}
    await page.type("Browserbase");
    ```

    <ParamField path="text" type="string">
      The text to type.
    </ParamField>

    <ParamField path="options" type="PageTypeOptions" optional>
      Options that configure this operation.

      <ParamField path="options.delay" type="number" optional>
        The input delay in milliseconds.
      </ParamField>

      <ParamField path="options.withMistakes" type="boolean" optional>
        Whether to simulate occasional typing mistakes.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="Promise<void>">
      Resolves after the operation completes.
    </ResponseField>

    ## keyPress()

    Send a keyboard key press to the page.

    ```typescript theme={null}
    await page.keyPress("Enter");
    ```

    <ParamField path="key" type="string">
      The keyboard key to send.
    </ParamField>

    <ParamField path="options" type="PageKeyPressOptions" optional>
      Options that configure this operation.

      <ParamField path="options.delay" type="number" optional>
        The input delay in milliseconds.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="Promise<void>">
      Resolves after the operation completes.
    </ResponseField>

    ## evaluate()

    Evaluate JavaScript in the page and return its result.

    ```typescript theme={null}
    const title = await page.evaluate(() => document.title);
    ```

    <ParamField path="expression" type="string | ((arg: Arg) => R | Promise<R>)">
      JavaScript source or a function to evaluate.
    </ParamField>

    <ParamField path="arg" type="Arg" optional>
      An optional argument passed to the function.
    </ParamField>

    <ResponseField name="result" type="Promise<R>">
      The operation result.
    </ResponseField>

    ## on()

    Subscribe to console messages from this page and its page-owned sessions. Stagehand
    delivers each message using the underlying `"Runtime.consoleAPICalled"` event envelope.

    ```typescript theme={null}
    const subscription = await page.on("console", (event) => {
      console.log(event.method, event.params);
    });

    await page.evaluate(() => console.log("ready"));
    await subscription.unsubscribe();
    ```

    <ParamField path="event" type="PageEventName">
      The console event name. Currently, the only supported value is `"console"`.
    </ParamField>

    <ParamField path="listener" type="PageEventListener">
      A callback that receives the event method, raw parameters, session ID, target ID,
      and page ID. Async callbacks may overlap and are not awaited by later page calls.
    </ParamField>

    <ResponseField name="result" type="Promise<CDPSubscription>">
      A subscription handle whose `unsubscribe()` method stops delivery.
    </ResponseField>

    ### CDPSubscription

    `unsubscribe(): Promise<void>` removes the listener locally and from the Stagehand runtime.
    Repeated calls share the completed cleanup. A failed runtime request can be retried by calling
    `unsubscribe()` again.

    ## addInitScript()

    Run a script before other scripts whenever the page navigates.

    ```typescript theme={null}
    await page.addInitScript(() => {
      window.localStorage.clear();
    });
    ```

    <ParamField path="script" type="InitScriptSource<Arg>">
      A function, JavaScript source string, or object with exactly one of `path` and `content`.
    </ParamField>

    <ParamField path="arg" type="Arg" optional>
      An optional JSON-serializable argument. Valid only when `script` is a function.
    </ParamField>

    <ResponseField name="result" type="Promise<void>">
      Resolves after the operation completes.
    </ResponseField>

    ## setExtraHTTPHeaders()

    Set additional HTTP headers for this page.

    ```typescript theme={null}
    await page.setExtraHTTPHeaders({ "x-test": "true" });
    ```

    <ParamField path="headers" type="Record<string, string>">
      HTTP header names and values.
    </ParamField>

    <ResponseField name="result" type="Promise<void>">
      Resolves after the operation completes.
    </ResponseField>

    ## setViewportSize()

    Set the page viewport dimensions.

    ```typescript theme={null}
    await page.setViewportSize(1440, 900);
    ```

    <ParamField path="width" type="number">
      Viewport width in CSS pixels.
    </ParamField>

    <ParamField path="height" type="number">
      Viewport height in CSS pixels.
    </ParamField>

    <ParamField path="options" type="PageSetViewportSizeOptions" optional>
      Options that configure this operation.

      <ParamField path="options.deviceScaleFactor" type="number" optional>
        The device scale factor.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="Promise<void>">
      Resolves after the operation completes.
    </ResponseField>

    ## waitForLoadState()

    Wait until the page reaches a load state.

    ```typescript theme={null}
    await page.waitForLoadState("networkidle", 10_000);
    ```

    <ParamField path="state" type="LoadState">
      The state to wait for: `"load"`, `"domcontentloaded"`, or `"networkidle"`.
    </ParamField>

    <ParamField path="timeout" type="number" optional>
      Maximum wait time in milliseconds.
    </ParamField>

    <ResponseField name="result" type="Promise<void>">
      Resolves after the operation completes.
    </ResponseField>

    ## waitForTimeout()

    Wait for a fixed number of milliseconds.

    ```typescript theme={null}
    await page.waitForTimeout(500);
    ```

    <ParamField path="ms" type="number">
      The number of milliseconds to wait.
    </ParamField>

    <ResponseField name="result" type="Promise<void>">
      Resolves after the operation completes.
    </ResponseField>

    ## waitForSelector()

    Wait for a selector to reach the requested state.

    ```typescript theme={null}
    const matched = await page.waitForSelector("main");
    ```

    <ParamField path="selector" type="string">
      The selector to target.
    </ParamField>

    <ParamField path="options" type="PageWaitForSelectorOptions" optional>
      Options that configure this operation.

      <ParamField path="options.pierceShadow" type="boolean" optional>
        Whether to traverse shadow roots. Closed roots require a navigated page; see the [locator reference](/v4/reference/locator).
      </ParamField>

      <ParamField path="options.state" type="PageWaitForSelectorOptions['state']" optional>
        The state to wait for: `"attached"`, `"detached"`, `"visible"`, or `"hidden"`.
      </ParamField>

      <ParamField path="options.timeout" type="number" optional>
        The operation timeout in milliseconds.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="Promise<boolean>">
      The operation result.
    </ResponseField>

    ## screenshot()

    Capture a screenshot of the page.

    ```typescript theme={null}
    const image = await page.screenshot({ fullPage: true });
    ```

    <ParamField path="options" type="ScreenshotOptions" optional>
      Options that configure this operation.

      <ParamField path="options.animations" type="ScreenshotOptions['animations']" optional>
        How to handle active animations: `"disabled"` or `"allow"`.
      </ParamField>

      <ParamField path="options.caret" type="ScreenshotOptions['caret']" optional>
        How to render the text caret: `"hide"` or `"initial"`.
      </ParamField>

      <ParamField path="options.clip" type="PageScreenshotClip" optional>
        The screenshot crop rectangle.

        <ParamField path="options.clip.height" type="number">
          The positive height in CSS pixels.
        </ParamField>

        <ParamField path="options.clip.width" type="number">
          The positive width in CSS pixels.
        </ParamField>

        <ParamField path="options.clip.x" type="number">
          The horizontal coordinate.
        </ParamField>

        <ParamField path="options.clip.y" type="number">
          The vertical coordinate.
        </ParamField>
      </ParamField>

      <ParamField path="options.fullPage" type="boolean" optional>
        Whether to capture the full scrollable page. Cannot be combined with `clip`.
      </ParamField>

      <ParamField path="options.mask" type="Locator[]" optional>
        Page-created locators for elements to obscure. Every locator must belong to this page.
      </ParamField>

      <ParamField path="options.maskColor" type="string" optional>
        The CSS mask color.
      </ParamField>

      <ParamField path="options.omitBackground" type="boolean" optional>
        Whether to use a transparent background.
      </ParamField>

      <ParamField path="options.path" type="string" optional>
        A file path where the image is also written.
      </ParamField>

      <ParamField path="options.quality" type="number" optional>
        JPEG quality as an integer from 0 to 100. Valid only when `type` is `"jpeg"`.
      </ParamField>

      <ParamField path="options.scale" type="ScreenshotOptions['scale']" optional>
        Whether to use `"css"` or `"device"` pixel scale.
      </ParamField>

      <ParamField path="options.style" type="string" optional>
        CSS applied while taking the screenshot.
      </ParamField>

      <ParamField path="options.timeout" type="number" optional>
        The non-negative operation timeout in milliseconds.
      </ParamField>

      <ParamField path="options.type" type="ScreenshotOptions['type']" optional>
        The image format: `"png"` or `"jpeg"`.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="Promise<Uint8Array>">
      The screenshot image bytes.
    </ResponseField>

    ## snapshot()

    Capture the page's accessibility-oriented DOM snapshot.

    ```typescript theme={null}
    const snapshot = await page.snapshot();
    ```

    <ParamField path="options" type="PageSnapshotOptions" optional>
      Options that configure this operation.

      <ParamField path="options.includeIframes" type="boolean" optional>
        Whether to include iframe content.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="Promise<SnapshotResult>">
      The operation result.

      <ResponseField name="result.formattedTree" type="string">
        The formatted page tree.
      </ResponseField>

      <ResponseField name="result.urlMap" type="object">
        The snapshot URL lookup.
      </ResponseField>

      <ResponseField name="result.xpathMap" type="object">
        The snapshot XPath lookup.
      </ResponseField>
    </ResponseField>

    ## tools()

    Return the WebMCP tools registered on the page.

    ```typescript theme={null}
    const tools = await page.tools();

    const searchTool = tools.find((tool) => tool.name === "search");
    if (!searchTool) throw new Error("Search tool is unavailable");

    console.log(searchTool.inputSchema);

    const invocation = await searchTool.invoke({
      input: { query: "Stagehand" },
    });
    const result = await invocation.result();
    console.log(result.status, result.output);
    ```

    <ParamField path="options" type="WebMCPToolsOptions" optional>
      Options that configure tool discovery.

      <ParamField path="options.timeout" type="number" optional>
        Maximum time in milliseconds to wait for registered tools.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="Promise<WebMCPTool[]>">
      The callable WebMCP tools registered on the page. See the
      [WebMCP reference](/v4/reference/webmcp).
    </ResponseField>

    ## url()

    Return the page's current URL.

    ```typescript theme={null}
    const url = await page.url();
    ```

    <ResponseField name="result" type="Promise<string>">
      The operation result.
    </ResponseField>

    ## title()

    Return the page's current document title.

    ```typescript theme={null}
    const title = await page.title();
    ```

    <ResponseField name="result" type="Promise<string>">
      The operation result.
    </ResponseField>

    ## close()

    Close the page.

    ```typescript theme={null}
    await page.close();
    ```

    <ResponseField name="result" type="Promise<void>">
      Resolves after the operation completes.
    </ResponseField>

    ## locator()

    Create a locator for a CSS selector on this page.

    ```typescript theme={null}
    const locator = page.locator("button[type=submit]");
    ```

    <ParamField path="selector" type="string">
      The selector to target.
    </ParamField>

    <ResponseField name="result" type="Locator">
      The operation result.
    </ResponseField>
  </Tab>

  <Tab title="Python">
    ## Quick start

    ```python theme={null}
    page = await browser.context.new_page()
    response = await page.goto("https://example.com")
    ```

    ## goto()

    Navigate the page to a URL.

    ```python theme={null}
    response = await page.goto("https://example.com")
    ```

    <ParamField path="url" type="str">
      The destination URL.
    </ParamField>

    <ParamField path="wait_until" type="LoadState | Literal['load', 'domcontentloaded', 'networkidle']" optional>
      The load state to wait for. Defaults to `"domcontentloaded"`.
    </ParamField>

    <ParamField path="timeout" type="int | None" optional>
      Maximum wait time in milliseconds.
    </ParamField>

    <ResponseField name="result" type="Response | None">
      The final main-document response, or `None` when no network response was produced.
    </ResponseField>

    ## reload()

    Reload the current page.

    ```python theme={null}
    await page.reload()
    ```

    <ParamField path="wait_until" type="LoadState | Literal['load', 'domcontentloaded', 'networkidle']" optional>
      The load state to wait for. Defaults to `"domcontentloaded"`.
    </ParamField>

    <ParamField path="timeout" type="int | None" optional>
      Maximum wait time in milliseconds.
    </ParamField>

    <ParamField path="ignore_cache" type="bool | None" optional>
      Whether to bypass the browser cache.
    </ParamField>

    <ResponseField name="result" type="Response | None">
      The final main-document response, or `None` when no network response was produced.
    </ResponseField>

    ## go\_back()

    Navigate backward in the page history.

    ```python theme={null}
    await page.go_back()
    ```

    <ParamField path="wait_until" type="LoadState | Literal['load', 'domcontentloaded', 'networkidle']" optional>
      The load state to wait for. Defaults to `"domcontentloaded"`.
    </ParamField>

    <ParamField path="timeout" type="int | None" optional>
      Maximum wait time in milliseconds.
    </ParamField>

    <ResponseField name="result" type="Response | None">
      The final main-document response, or `None` when no history navigation occurred or no network response was produced.
    </ResponseField>

    ## go\_forward()

    Navigate forward in the page history.

    ```python theme={null}
    await page.go_forward()
    ```

    <ParamField path="wait_until" type="LoadState | Literal['load', 'domcontentloaded', 'networkidle']" optional>
      The load state to wait for. Defaults to `"domcontentloaded"`.
    </ParamField>

    <ParamField path="timeout" type="int | None" optional>
      Maximum wait time in milliseconds.
    </ParamField>

    <ResponseField name="result" type="Response | None">
      The final main-document response, or `None` when no history navigation occurred or no network response was produced.
    </ResponseField>

    ## click()

    Click at page coordinates.

    ```python theme={null}
    await page.click(240, 320)
    ```

    <ParamField path="x" type="float">
      The horizontal page coordinate.
    </ParamField>

    <ParamField path="y" type="float">
      The vertical page coordinate.
    </ParamField>

    <ParamField path="button" type="MouseButton | Literal['left', 'right', 'middle']" optional>
      The mouse button to use.
    </ParamField>

    <ParamField path="click_count" type="int | None" optional>
      The number of clicks to dispatch.
    </ParamField>

    <ResponseField name="result" type="None">
      Resolves after the operation completes.
    </ResponseField>

    ## hover()

    Move the pointer to page coordinates.

    ```python theme={null}
    await page.hover(240, 320)
    ```

    <ParamField path="x" type="float">
      The horizontal page coordinate.
    </ParamField>

    <ParamField path="y" type="float">
      The vertical page coordinate.
    </ParamField>

    <ResponseField name="result" type="None">
      Resolves after the operation completes.
    </ResponseField>

    ## scroll()

    Scroll from page coordinates by the supplied deltas.

    ```python theme={null}
    await page.scroll(240, 320, 0, 600)
    ```

    <ParamField path="x" type="float">
      The horizontal page coordinate.
    </ParamField>

    <ParamField path="y" type="float">
      The vertical page coordinate.
    </ParamField>

    <ParamField path="delta_x" type="float">
      Horizontal scroll distance.
    </ParamField>

    <ParamField path="delta_y" type="float">
      Vertical scroll distance.
    </ParamField>

    <ResponseField name="result" type="None">
      Resolves after the operation completes.
    </ResponseField>

    ## drag\_and\_drop()

    Drag from one page coordinate to another.

    ```python theme={null}
    await page.drag_and_drop(100, 100, 400, 400)
    ```

    <ParamField path="from_x" type="float">
      The drag origin's horizontal coordinate.
    </ParamField>

    <ParamField path="from_y" type="float">
      The drag origin's vertical coordinate.
    </ParamField>

    <ParamField path="to_x" type="float">
      The drop target's horizontal coordinate.
    </ParamField>

    <ParamField path="to_y" type="float">
      The drop target's vertical coordinate.
    </ParamField>

    <ParamField path="button" type="MouseButton | Literal['left', 'right', 'middle']" optional>
      The mouse button to use.
    </ParamField>

    <ParamField path="steps" type="int | None" optional>
      The number of intermediate pointer moves.
    </ParamField>

    <ParamField path="delay" type="float | None" optional>
      An optional input delay in milliseconds.
    </ParamField>

    <ParamField path="route" type="Sequence[PageDragAndDropRoutePoint | Mapping[str, float]] | None" optional>
      An ordered mouse route to follow instead of generating linear intermediate moves. The explicit
      `to_x` and `to_y` coordinates remain the final point.

      <ParamField path="route.x" type="float">
        A route point's horizontal coordinate.
      </ParamField>

      <ParamField path="route.y" type="float">
        A route point's vertical coordinate.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="None">
      Resolves after the operation completes.
    </ResponseField>

    ## type()

    Type text at the current input target.

    ```python theme={null}
    await page.type("Browserbase")
    ```

    <ParamField path="text" type="str">
      The text to type.
    </ParamField>

    <ParamField path="delay" type="float | None" optional>
      An optional input delay in milliseconds.
    </ParamField>

    <ParamField path="with_mistakes" type="bool | None" optional>
      Whether to simulate occasional typing mistakes.
    </ParamField>

    <ResponseField name="result" type="None">
      Resolves after the operation completes.
    </ResponseField>

    ## key\_press()

    Send a keyboard key press to the page.

    ```python theme={null}
    await page.key_press("Enter")
    ```

    <ParamField path="key" type="str">
      The keyboard key to send.
    </ParamField>

    <ParamField path="delay" type="float | None" optional>
      An optional input delay in milliseconds.
    </ParamField>

    <ResponseField name="result" type="None">
      Resolves after the operation completes.
    </ResponseField>

    ## evaluate()

    Evaluate JavaScript in the page and return its result.

    ```python theme={null}
    title = await page.evaluate("document.title", result_type=str)
    ```

    <ParamField path="expression" type="str">
      JavaScript source or a function to evaluate.
    </ParamField>

    <ParamField path="result_type" type="type[EvaluateResult] | None" optional>
      An optional Python type used to validate the result.
    </ParamField>

    <ResponseField name="result" type="JsonValue | EvaluateResult">
      The operation result.
    </ResponseField>

    ## on()

    Subscribe to console messages from this page and its page-owned sessions. Stagehand
    delivers each message using the underlying `"Runtime.consoleAPICalled"` event envelope.

    ```python theme={null}
    async def handle_console(event: PageCDPEvent) -> None:
        print(event.method, event.params)

    subscription = await page.on("console", handle_console)
    await page.evaluate('console.log("ready")')
    await subscription.unsubscribe()
    ```

    <ParamField path="event" type="PageEventName">
      The console event name. Currently, the only supported value is `"console"`.
    </ParamField>

    <ParamField path="listener" type="PageEventListener">
      A sync or async callback that receives the event method, raw parameters, session
      ID, target ID, and page ID. Async callbacks may overlap and are not awaited by
      later page calls.
    </ParamField>

    <ResponseField name="result" type="CDPSubscription">
      A subscription handle whose `unsubscribe()` method stops delivery.
    </ResponseField>

    ### CDPSubscription

    `await subscription.unsubscribe()` removes the listener locally and from the Stagehand runtime.
    Repeated calls await the same successful cleanup. Failed cleanup can be retried. If the caller is
    cancelled while awaiting cleanup, the shared cleanup task continues in the background.

    ## add\_init\_script()

    Run a script before other scripts whenever the page navigates.

    ```python theme={null}
    await page.add_init_script("window.localStorage.clear()")
    ```

    <ParamField path="source" type="str | Path">
      JavaScript source or a path to a JavaScript file on the SDK caller's machine.
    </ParamField>

    <ResponseField name="result" type="None">
      Resolves after the operation completes.
    </ResponseField>

    ## set\_extra\_http\_headers()

    Set additional HTTP headers for this page.

    ```python theme={null}
    await page.set_extra_http_headers({"x-test": "true"})
    ```

    <ParamField path="headers" type="Mapping[str, str]">
      HTTP header names and values.
    </ParamField>

    <ResponseField name="result" type="None">
      Resolves after the operation completes.
    </ResponseField>

    ## set\_viewport\_size()

    Set the page viewport dimensions.

    ```python theme={null}
    await page.set_viewport_size(1440, 900)
    ```

    <ParamField path="width" type="int">
      Viewport width in CSS pixels.
    </ParamField>

    <ParamField path="height" type="int">
      Viewport height in CSS pixels.
    </ParamField>

    <ParamField path="device_scale_factor" type="float | None" optional>
      The device scale factor.
    </ParamField>

    <ResponseField name="result" type="None">
      Resolves after the operation completes.
    </ResponseField>

    ## wait\_for\_load\_state()

    Wait until the page reaches a load state.

    ```python theme={null}
    await page.wait_for_load_state("networkidle", timeout=10_000)
    ```

    <ParamField path="state" type="LoadState | Literal['load', 'domcontentloaded', 'networkidle']">
      The state to wait for: `"load"`, `"domcontentloaded"`, or `"networkidle"`.
    </ParamField>

    <ParamField path="timeout" type="int | None" optional>
      Maximum wait time in milliseconds.
    </ParamField>

    <ResponseField name="result" type="None">
      Resolves after the operation completes.
    </ResponseField>

    ## wait\_for\_timeout()

    Wait for a fixed number of milliseconds.

    ```python theme={null}
    await page.wait_for_timeout(500)
    ```

    <ParamField path="ms" type="int">
      The number of milliseconds to wait.
    </ParamField>

    <ResponseField name="result" type="None">
      Resolves after the operation completes.
    </ResponseField>

    ## wait\_for\_selector()

    Wait for a selector to reach the requested state.

    ```python theme={null}
    matched = await page.wait_for_selector("main", state="visible")
    ```

    <ParamField path="selector" type="str">
      The selector to target.
    </ParamField>

    <ParamField path="state" type="State | Literal['attached', 'detached', 'visible', 'hidden']" optional>
      The state to wait for: `"attached"`, `"detached"`, `"visible"`, or `"hidden"`.
    </ParamField>

    <ParamField path="timeout" type="int | None" optional>
      Maximum wait time in milliseconds.
    </ParamField>

    <ParamField path="pierce_shadow" type="bool | None" optional>
      Whether to traverse shadow roots. Closed roots require a navigated page; see the [locator reference](/v4/reference/locator).
    </ParamField>

    <ResponseField name="result" type="bool">
      The operation result.
    </ResponseField>

    ## screenshot()

    Capture a screenshot of the page.

    ```python theme={null}
    image = await page.screenshot(full_page=True)
    ```

    <ParamField path="animations" type="Animations | Literal['disabled', 'allow']" optional>
      How to handle CSS animations: `"disabled"` or `"allow"`.
    </ParamField>

    <ParamField path="caret" type="Caret | Literal['hide', 'initial']" optional>
      How to render the text caret: `"hide"` or `"initial"`.
    </ParamField>

    <ParamField path="clip" type="PageScreenshotClip | None" optional>
      The region to capture.

      <ParamField path="clip.height" type="float">
        The positive height in CSS pixels.
      </ParamField>

      <ParamField path="clip.width" type="float">
        The positive width in CSS pixels.
      </ParamField>

      <ParamField path="clip.x" type="float">
        The horizontal coordinate.
      </ParamField>

      <ParamField path="clip.y" type="float">
        The vertical coordinate.
      </ParamField>
    </ParamField>

    <ParamField path="full_page" type="bool | None" optional>
      Whether to capture the full scrollable page. Cannot be combined with `clip`.
    </ParamField>

    <ParamField path="path" type="str | Path | None" optional>
      A path where the image is also written.
    </ParamField>

    <ParamField path="mask" type="Sequence[Locator] | None" optional>
      Page-created locators for elements to obscure. Every locator must belong to this page.
    </ParamField>

    <ParamField path="mask_color" type="str | None" optional>
      The CSS color used for masks.
    </ParamField>

    <ParamField path="omit_background" type="bool | None" optional>
      Whether to use a transparent background.
    </ParamField>

    <ParamField path="quality" type="int | None" optional>
      JPEG quality as an integer from 0 to 100. Valid only when `type` is `"jpeg"`.
    </ParamField>

    <ParamField path="scale" type="Scale | Literal['css', 'device']" optional>
      Whether to use `"css"` or `"device"` pixel scale.
    </ParamField>

    <ParamField path="style" type="str | None" optional>
      CSS applied while taking the screenshot.
    </ParamField>

    <ParamField path="timeout" type="float | None" optional>
      Maximum non-negative wait time in milliseconds.
    </ParamField>

    <ParamField path="type" type="ScreenshotType | Literal['png', 'jpeg']" optional>
      The image format: `"png"` or `"jpeg"`.
    </ParamField>

    <ResponseField name="result" type="bytes">
      The operation result.
    </ResponseField>

    ## snapshot()

    Capture the page's accessibility-oriented DOM snapshot.

    ```python theme={null}
    snapshot = await page.snapshot()
    ```

    <ParamField path="include_iframes" type="bool | None" optional>
      Whether to include iframe content.
    </ParamField>

    <ResponseField name="result" type="SnapshotResult">
      The operation result.

      <ResponseField name="result.formatted_tree" type="str">
        The formatted page tree.
      </ResponseField>

      <ResponseField name="result.url_map" type="dict[str, object]">
        The snapshot URL lookup.
      </ResponseField>

      <ResponseField name="result.xpath_map" type="dict[str, object]">
        The snapshot XPath lookup.
      </ResponseField>
    </ResponseField>

    ## tools()

    Return the WebMCP tools registered on the page.

    ```python theme={null}
    tools = await page.tools()

    search_tool = next((tool for tool in tools if tool.name == "search"), None)
    if search_tool is None:
        raise RuntimeError("Search tool is unavailable")

    print(search_tool.input_schema)

    invocation = await search_tool.invoke(input={"query": "Stagehand"})
    result = await invocation.result()
    print(result.status, result.output)
    ```

    <ParamField path="timeout" type="float | None" optional>
      Maximum time in milliseconds to wait for registered tools.
    </ParamField>

    <ResponseField name="result" type="list[WebMCPTool]">
      The callable WebMCP tools registered on the page. See the
      [WebMCP reference](/v4/reference/webmcp).
    </ResponseField>

    ## url()

    Return the page's current URL.

    ```python theme={null}
    url = await page.url()
    ```

    <ResponseField name="result" type="str">
      The operation result.
    </ResponseField>

    ## title()

    Return the page's current document title.

    ```python theme={null}
    title = await page.title()
    ```

    <ResponseField name="result" type="str">
      The operation result.
    </ResponseField>

    ## close()

    Close the page.

    ```python theme={null}
    await page.close()
    ```

    <ResponseField name="result" type="None">
      Resolves after the operation completes.
    </ResponseField>

    ## locator()

    Create a locator for a CSS selector on this page.

    ```python theme={null}
    locator = page.locator("button[type=submit]")
    ```

    <ParamField path="selector" type="str">
      The selector to target.
    </ParamField>

    <ResponseField name="result" type="Locator">
      The operation result.
    </ResponseField>
  </Tab>

  <Tab title="Go">
    ## Quick start

    ```go theme={null}
    browserContext, err := browser.Context()
    if err != nil {
        return err
    }
    page, err := browserContext.NewPage(ctx)
    if err != nil {
        return err
    }
    if _, err := page.Goto(ctx, "https://example.com", nil); err != nil {
        return err
    }
    ```

    Every method that talks to the browser takes a `context.Context` first and returns an `error` last; the local `Locator()` accessor takes neither. Options are passed as pointer structs; pass `nil` for defaults.

    ## Goto()

    Navigate the page to a URL.

    ```go theme={null}
    if _, err := page.Goto(ctx, "https://example.com", nil); err != nil {
        return err
    }
    ```

    <ParamField path="url" type="string">
      The destination URL.
    </ParamField>

    <ParamField path="options" type="*PageNavigationOptions" optional>
      Options that configure this operation. Pass `nil` for defaults.

      <ParamField path="options.Timeout" type="*int" optional>
        Maximum wait time in milliseconds.
      </ParamField>

      <ParamField path="options.WaitUntil" type="*LoadState" optional>
        The target load state: `LoadStateLoad`, `LoadStateDOMContentLoaded`, or
        `LoadStateNetworkIdle`. Defaults to `LoadStateDOMContentLoaded`.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="(*Response, error)">
      The final main-document response, or `nil` when no network response was produced.
    </ResponseField>

    ## Reload()

    Reload the current page.

    ```go theme={null}
    if _, err := page.Reload(ctx, nil); err != nil {
        return err
    }
    ```

    <ParamField path="options" type="*PageReloadOptions" optional>
      Options that configure this operation. Pass `nil` for defaults.

      <ParamField path="options.IgnoreCache" type="*bool" optional>
        Whether to bypass the browser cache.
      </ParamField>

      <ParamField path="options.Timeout" type="*int" optional>
        Maximum wait time in milliseconds.
      </ParamField>

      <ParamField path="options.WaitUntil" type="*LoadState" optional>
        The target load state: `LoadStateLoad`, `LoadStateDOMContentLoaded`, or
        `LoadStateNetworkIdle`. Defaults to `LoadStateDOMContentLoaded`.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="(*Response, error)">
      The final main-document response, or `nil` when no network response was produced.
    </ResponseField>

    ## GoBack()

    Navigate backward in the page history.

    ```go theme={null}
    if _, err := page.GoBack(ctx, nil); err != nil {
        return err
    }
    ```

    <ParamField path="options" type="*PageNavigationOptions" optional>
      Options that configure this operation. Pass `nil` for defaults.

      <ParamField path="options.Timeout" type="*int" optional>
        Maximum wait time in milliseconds.
      </ParamField>

      <ParamField path="options.WaitUntil" type="*LoadState" optional>
        The target load state: `LoadStateLoad`, `LoadStateDOMContentLoaded`, or
        `LoadStateNetworkIdle`. Defaults to `LoadStateDOMContentLoaded`.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="(*Response, error)">
      The final main-document response, or `nil` when no history navigation occurred or no network response was produced.
    </ResponseField>

    ## GoForward()

    Navigate forward in the page history.

    ```go theme={null}
    if _, err := page.GoForward(ctx, nil); err != nil {
        return err
    }
    ```

    <ParamField path="options" type="*PageNavigationOptions" optional>
      Options that configure this operation. Pass `nil` for defaults.

      <ParamField path="options.Timeout" type="*int" optional>
        Maximum wait time in milliseconds.
      </ParamField>

      <ParamField path="options.WaitUntil" type="*LoadState" optional>
        The target load state: `LoadStateLoad`, `LoadStateDOMContentLoaded`, or
        `LoadStateNetworkIdle`. Defaults to `LoadStateDOMContentLoaded`.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="(*Response, error)">
      The final main-document response, or `nil` when no history navigation occurred or no network response was produced.
    </ResponseField>

    ## Click()

    Click at page coordinates.

    ```go theme={null}
    if err := page.Click(ctx, 240, 320, nil); err != nil {
        return err
    }
    ```

    <ParamField path="x" type="float64">
      The horizontal page coordinate.
    </ParamField>

    <ParamField path="y" type="float64">
      The vertical page coordinate.
    </ParamField>

    <ParamField path="options" type="*PageClickOptions" optional>
      Options that configure this operation. Pass `nil` for defaults.

      <ParamField path="options.Button" type="*MouseButton" optional>
        The mouse button to use: `MouseButtonLeft`, `MouseButtonMiddle`, or `MouseButtonRight`.
      </ParamField>

      <ParamField path="options.ClickCount" type="*int" optional>
        The number of clicks to dispatch.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="error">
      Returns `nil` after the operation completes.
    </ResponseField>

    ## Hover()

    Move the pointer to page coordinates.

    ```go theme={null}
    if err := page.Hover(ctx, 240, 320); err != nil {
        return err
    }
    ```

    <ParamField path="x" type="float64">
      The horizontal page coordinate.
    </ParamField>

    <ParamField path="y" type="float64">
      The vertical page coordinate.
    </ParamField>

    <ResponseField name="result" type="error">
      Returns `nil` after the operation completes.
    </ResponseField>

    ## Scroll()

    Scroll from page coordinates by the supplied deltas.

    ```go theme={null}
    if err := page.Scroll(ctx, 240, 320, 0, 600); err != nil {
        return err
    }
    ```

    <ParamField path="x" type="float64">
      The horizontal page coordinate.
    </ParamField>

    <ParamField path="y" type="float64">
      The vertical page coordinate.
    </ParamField>

    <ParamField path="deltaX" type="float64">
      Horizontal scroll distance.
    </ParamField>

    <ParamField path="deltaY" type="float64">
      Vertical scroll distance.
    </ParamField>

    <ResponseField name="result" type="error">
      Returns `nil` after the operation completes.
    </ResponseField>

    ## DragAndDrop()

    Drag from one page coordinate to another.

    ```go theme={null}
    if err := page.DragAndDrop(ctx, 100, 100, 400, 400, nil); err != nil {
        return err
    }
    ```

    <ParamField path="fromX" type="float64">
      The drag origin's horizontal coordinate.
    </ParamField>

    <ParamField path="fromY" type="float64">
      The drag origin's vertical coordinate.
    </ParamField>

    <ParamField path="toX" type="float64">
      The drop target's horizontal coordinate.
    </ParamField>

    <ParamField path="toY" type="float64">
      The drop target's vertical coordinate.
    </ParamField>

    <ParamField path="options" type="*PageDragAndDropOptions" optional>
      Options that configure this operation. Pass `nil` for defaults.

      <ParamField path="options.Button" type="*MouseButton" optional>
        The mouse button to use: `MouseButtonLeft`, `MouseButtonMiddle`, or `MouseButtonRight`.
      </ParamField>

      <ParamField path="options.Delay" type="*float64" optional>
        The input delay in milliseconds.
      </ParamField>

      <ParamField path="options.Steps" type="*int" optional>
        The number of intermediate pointer moves.
      </ParamField>

      <ParamField path="options.Route" type="[]PageDragAndDropRoutePoint" optional>
        An ordered mouse route to follow instead of generating linear intermediate moves. The explicit
        `toX` and `toY` coordinates remain the final point.

        <ParamField path="options.Route.X" type="float64">
          A route point's horizontal coordinate.
        </ParamField>

        <ParamField path="options.Route.Y" type="float64">
          A route point's vertical coordinate.
        </ParamField>
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="error">
      Returns `nil` after the operation completes.
    </ResponseField>

    ## Type()

    Type text at the current input target.

    ```go theme={null}
    if err := page.Type(ctx, "Browserbase", nil); err != nil {
        return err
    }
    ```

    <ParamField path="value" type="string">
      The text to type.
    </ParamField>

    <ParamField path="options" type="*PageTypeOptions" optional>
      Options that configure this operation. Pass `nil` for defaults.

      <ParamField path="options.Delay" type="*float64" optional>
        The input delay in milliseconds.
      </ParamField>

      <ParamField path="options.WithMistakes" type="*bool" optional>
        Whether to simulate occasional typing mistakes.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="error">
      Returns `nil` after the operation completes.
    </ResponseField>

    ## KeyPress()

    Send a keyboard key press to the page.

    ```go theme={null}
    if err := page.KeyPress(ctx, "Enter", nil); err != nil {
        return err
    }
    ```

    <ParamField path="key" type="string">
      The keyboard key to send.
    </ParamField>

    <ParamField path="options" type="*PageKeyPressOptions" optional>
      Options that configure this operation. Pass `nil` for defaults.

      <ParamField path="options.Delay" type="*float64" optional>
        The input delay in milliseconds.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="error">
      Returns `nil` after the operation completes.
    </ResponseField>

    ## Evaluate()

    Evaluate JavaScript in the page and return its result. `Evaluate` returns the raw JSON
    value; use the package-level generic `EvaluateAs` to decode the result into a Go type.

    ```go theme={null}
    title, err := stagehand.EvaluateAs[string](ctx, page, "document.title")
    if err != nil {
        return err
    }
    fmt.Println(title)
    ```

    <ParamField path="expression" type="string">
      JavaScript source to evaluate.
    </ParamField>

    <ResponseField name="result" type="(json.RawMessage, error)">
      The operation result as raw JSON. `EvaluateAs[T]` decodes it into `T` instead.
    </ResponseField>

    ## On()

    Subscribe to console messages from this page and its page-owned sessions. Stagehand
    delivers each message using the underlying `"Runtime.consoleAPICalled"` event envelope.

    ```go theme={null}
    subscription, err := page.On(ctx, stagehand.PageEventNameConsole, func(event stagehand.PageCDPEvent) {
        fmt.Println(event.Method, event.Params)
    })
    if err != nil {
        return err
    }

    if _, err := page.Evaluate(ctx, `console.log("ready")`); err != nil {
        return err
    }
    if err := subscription.Close(ctx); err != nil {
        return err
    }
    ```

    <ParamField path="event" type="PageEventName">
      The console event name. Currently, the only supported value is `PageEventNameConsole`.
    </ParamField>

    <ParamField path="listener" type="func(PageCDPEvent)">
      A callback that receives the event method, raw parameters, session ID, target ID,
      and page ID. Listeners are not awaited by later page calls.
    </ParamField>

    <ResponseField name="result" type="(*CDPSubscription, error)">
      A subscription handle whose `Close()` method stops delivery.
    </ResponseField>

    ### CDPSubscription

    `Close(ctx context.Context) error` removes the listener locally and from the Stagehand runtime.
    Repeated calls after successful cleanup return `nil`. Concurrent calls share the active cleanup;
    a failed attempt can be retried.

    ## AddInitScript()

    Run a script before other scripts whenever the page navigates.

    ```go theme={null}
    if err := page.AddInitScript(ctx, "window.localStorage.clear()"); err != nil {
        return err
    }
    ```

    <ParamField path="source" type="string">
      JavaScript source. Go functions and file paths are not interpreted.
    </ParamField>

    <ResponseField name="result" type="error">
      Returns `nil` after the operation completes.
    </ResponseField>

    ## SetExtraHTTPHeaders()

    Set additional HTTP headers for this page.

    ```go theme={null}
    headers := stagehand.PageSetExtraHTTPHeadersParamsHeaders{"x-test": "true"}
    if err := page.SetExtraHTTPHeaders(ctx, headers); err != nil {
        return err
    }
    ```

    <ParamField path="headers" type="PageSetExtraHTTPHeadersParamsHeaders">
      HTTP header names and values, as a `map[string]string`.
    </ParamField>

    <ResponseField name="result" type="error">
      Returns `nil` after the operation completes.
    </ResponseField>

    ## SetViewportSize()

    Set the page viewport dimensions.

    ```go theme={null}
    if err := page.SetViewportSize(ctx, 1440, 900, nil); err != nil {
        return err
    }
    ```

    <ParamField path="width" type="int">
      Viewport width in CSS pixels.
    </ParamField>

    <ParamField path="height" type="int">
      Viewport height in CSS pixels.
    </ParamField>

    <ParamField path="options" type="*PageSetViewportSizeOptions" optional>
      Options that configure this operation. Pass `nil` for defaults.

      <ParamField path="options.DeviceScaleFactor" type="*float64" optional>
        The device scale factor.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="error">
      Returns `nil` after the operation completes.
    </ResponseField>

    ## WaitForLoadState()

    Wait until the page reaches a load state.

    ```go theme={null}
    timeout := 10_000
    if err := page.WaitForLoadState(ctx, stagehand.LoadStateNetworkIdle, &timeout); err != nil {
        return err
    }
    ```

    <ParamField path="state" type="LoadState">
      The state to wait for: `LoadStateLoad`, `LoadStateDOMContentLoaded`, or `LoadStateNetworkIdle`.
    </ParamField>

    <ParamField path="timeoutMs" type="*int" optional>
      Maximum wait time in milliseconds. Pass `nil` for the default.
    </ParamField>

    <ResponseField name="result" type="error">
      Returns `nil` after the operation completes.
    </ResponseField>

    ## WaitForTimeout()

    Wait for a fixed number of milliseconds.

    ```go theme={null}
    if err := page.WaitForTimeout(ctx, 500); err != nil {
        return err
    }
    ```

    <ParamField path="ms" type="int">
      The number of milliseconds to wait.
    </ParamField>

    <ResponseField name="result" type="error">
      Returns `nil` after the operation completes.
    </ResponseField>

    ## WaitForSelector()

    Wait for a selector to reach the requested state.

    ```go theme={null}
    matched, err := page.WaitForSelector(ctx, "main", nil)
    if err != nil {
        return err
    }
    fmt.Println(matched)
    ```

    <ParamField path="selector" type="string">
      The selector to target.
    </ParamField>

    <ParamField path="options" type="*PageWaitForSelectorOptions" optional>
      Options that configure this operation. Pass `nil` for defaults.

      <ParamField path="options.PierceShadow" type="*bool" optional>
        Whether to traverse shadow roots. Closed roots require a navigated page; see the [locator reference](/v4/reference/locator).
      </ParamField>

      <ParamField path="options.State" type="*PageWaitForSelectorOptionsState" optional>
        The state to wait for: `PageWaitForSelectorOptionsStateAttached`,
        `PageWaitForSelectorOptionsStateDetached`, `PageWaitForSelectorOptionsStateVisible`, or
        `PageWaitForSelectorOptionsStateHidden`.
      </ParamField>

      <ParamField path="options.Timeout" type="*int" optional>
        The operation timeout in milliseconds.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="(bool, error)">
      The operation result.
    </ResponseField>

    ## Screenshot()

    Capture a screenshot of the page. There is no `path` option in Go; write the returned
    bytes yourself, for example with `os.WriteFile`.

    ```go theme={null}
    fullPage := true
    image, err := page.Screenshot(ctx, &stagehand.ScreenshotOptions{FullPage: &fullPage})
    if err != nil {
        return err
    }
    if err := os.WriteFile("screenshot.png", image, 0o644); err != nil {
        return err
    }
    ```

    <ParamField path="options" type="*ScreenshotOptions" optional>
      Options that configure this operation. Pass `nil` for defaults.

      <ParamField path="options.Animations" type="*PageScreenshotOptionsAnimations" optional>
        How to handle active animations: `PageScreenshotOptionsAnimationsDisabled` or
        `PageScreenshotOptionsAnimationsAllow`.
      </ParamField>

      <ParamField path="options.Caret" type="*PageScreenshotOptionsCaret" optional>
        How to render the text caret: `PageScreenshotOptionsCaretHide` or
        `PageScreenshotOptionsCaretInitial`.
      </ParamField>

      <ParamField path="options.Clip" type="*PageScreenshotClip" optional>
        The screenshot crop rectangle.

        <ParamField path="options.Clip.Height" type="float64">
          The positive height in CSS pixels.
        </ParamField>

        <ParamField path="options.Clip.Width" type="float64">
          The positive width in CSS pixels.
        </ParamField>

        <ParamField path="options.Clip.X" type="float64">
          The horizontal coordinate.
        </ParamField>

        <ParamField path="options.Clip.Y" type="float64">
          The vertical coordinate.
        </ParamField>
      </ParamField>

      <ParamField path="options.FullPage" type="*bool" optional>
        Whether to capture the full scrollable page. Cannot be combined with `options.Clip`.
      </ParamField>

      <ParamField path="options.Mask" type="[]*PageLocator" optional>
        Page-created locators for elements to obscure in the screenshot. Create each with
        `page.Locator("...")`; every mask locator must belong to the page being captured.
      </ParamField>

      <ParamField path="options.MaskColor" type="*string" optional>
        The CSS mask color.
      </ParamField>

      <ParamField path="options.OmitBackground" type="*bool" optional>
        Whether to use a transparent background.
      </ParamField>

      <ParamField path="options.Quality" type="*int" optional>
        JPEG quality as an integer from 0 to 100. Valid only when `options.Type` is
        `PageScreenshotOptionsTypeJPEG`.
      </ParamField>

      <ParamField path="options.Scale" type="*PageScreenshotOptionsScale" optional>
        Whether to use `PageScreenshotOptionsScaleCSS` or `PageScreenshotOptionsScaleDevice`.
      </ParamField>

      <ParamField path="options.Style" type="*string" optional>
        CSS applied while taking the screenshot.
      </ParamField>

      <ParamField path="options.Timeout" type="*float64" optional>
        The non-negative operation timeout in milliseconds.
      </ParamField>

      <ParamField path="options.Type" type="*PageScreenshotOptionsType" optional>
        The image format: `PageScreenshotOptionsTypePNG` or `PageScreenshotOptionsTypeJPEG`.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="([]byte, error)">
      The screenshot image bytes.
    </ResponseField>

    ## Snapshot()

    Capture the page's accessibility-oriented DOM snapshot.

    ```go theme={null}
    snapshot, err := page.Snapshot(ctx, nil)
    if err != nil {
        return err
    }
    fmt.Println(snapshot.FormattedTree)
    ```

    <ParamField path="options" type="*PageSnapshotOptions" optional>
      Options that configure this operation. Pass `nil` for defaults.

      <ParamField path="options.IncludeIframes" type="*bool" optional>
        Whether to include iframe content.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="(SnapshotResult, error)">
      The operation result.

      <ResponseField name="result.FormattedTree" type="string">
        The formatted page tree.
      </ResponseField>

      <ResponseField name="result.URLMap" type="SnapshotResultURLMap">
        The snapshot URL lookup.
      </ResponseField>

      <ResponseField name="result.XPathMap" type="SnapshotResultXPathMap">
        The snapshot XPath lookup.
      </ResponseField>
    </ResponseField>

    ## Tools()

    Return the WebMCP tools registered on the page.

    ```go theme={null}
    tools, err := page.Tools(ctx, nil)
    if err != nil {
        return err
    }

    var searchTool *stagehand.WebMCPTool
    for _, tool := range tools {
        if tool.Descriptor().Name == "search" {
            searchTool = tool
            break
        }
    }
    if searchTool == nil {
        return errors.New("search tool is unavailable")
    }

    fmt.Println(searchTool.Descriptor().InputSchema)

    invocation, err := searchTool.Invoke(ctx, stagehand.WebMCPInput{"query": "Stagehand"})
    if err != nil {
        return err
    }
    result, err := invocation.Result(ctx, nil)
    if err != nil {
        return err
    }
    fmt.Println(result.Status, result.Output)
    ```

    <ParamField path="options" type="*WebMCPToolsOptions" optional>
      Options that configure tool discovery. Pass `nil` for defaults.

      <ParamField path="options.Timeout" type="float64" optional>
        Maximum time in milliseconds to wait for registered tools.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="([]*WebMCPTool, error)">
      The callable WebMCP tools registered on the page. See the
      [WebMCP reference](/v4/reference/webmcp).
    </ResponseField>

    ## URL()

    Return the page's current URL.

    ```go theme={null}
    url, err := page.URL(ctx)
    if err != nil {
        return err
    }
    fmt.Println(url)
    ```

    <ResponseField name="result" type="(string, error)">
      The operation result.
    </ResponseField>

    ## Title()

    Return the page's current document title.

    ```go theme={null}
    title, err := page.Title(ctx)
    if err != nil {
        return err
    }
    fmt.Println(title)
    ```

    <ResponseField name="result" type="(string, error)">
      The operation result.
    </ResponseField>

    ## Close()

    Close the page.

    ```go theme={null}
    if err := page.Close(ctx); err != nil {
        return err
    }
    ```

    <ResponseField name="result" type="error">
      Returns `nil` after the operation completes.
    </ResponseField>

    ## Locator()

    Create a locator for a CSS selector on this page.

    ```go theme={null}
    locator := page.Locator("button[type=submit]")
    if err := locator.Click(ctx, nil); err != nil {
        return err
    }
    ```

    <ParamField path="selector" type="string">
      The selector to target.
    </ParamField>

    <ResponseField name="result" type="*PageLocator">
      The operation result.
    </ResponseField>
  </Tab>
</Tabs>
