> ## 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.

# locator

> Target elements and perform focused DOM interactions

Create a `Locator` from a page selector, then reuse it for element interactions and state queries. `first()` and `nth()` refine the local locator descriptor; the resulting descriptor is sent with later operations.

Selectors pierce shadow DOM, including closed roots.

Selectors also cross iframe boundaries. Separate a frame from a target inside it with `>>`, and Stagehand resolves each hop in turn, so `page.locator("iframe#checkout >> button.submit")` reaches the button inside that iframe. Chain as many hops as the page nests. A deep XPath that steps through an iframe resolves the same way, as in `/html/body/iframe[2]//div`.

<Warning>
  **Closed roots require a navigated page.** Stagehand resolves elements inside iframes and shadow DOMs for you, so you rarely need to target nested documents manually. This relies on privileged browser APIs that aren't available on `about:blank` or `data:` URLs, so navigate to a `http:` or `https:` URL first when a target sits inside an iframe or a closed shadow root (see [locator limitations](/v4/reference/locator)).
</Warning>

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

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

    ## click()

    Click the element matched by this locator.

    ```typescript theme={null}
    await locator.click();
    ```

    <ParamField path="options" type="LocatorClickOptions" 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 over the matched element.

    ```typescript theme={null}
    await locator.hover();
    ```

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

    ## fill()

    Replace the matched input's value.

    ```typescript theme={null}
    await locator.fill("Browserbase");
    ```

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

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

    ## count()

    Count the elements matched by this locator.

    ```typescript theme={null}
    const count = await locator.count();
    ```

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

    ## isChecked()

    Check whether the matched control is checked.

    ```typescript theme={null}
    const checked = await locator.isChecked();
    ```

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

    ## inputValue()

    Return the current value of the matched input.

    ```typescript theme={null}
    const value = await locator.inputValue();
    ```

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

    ## isVisible()

    Check whether the matched element is visible.

    ```typescript theme={null}
    const visible = await locator.isVisible();
    ```

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

    ## innerText()

    Return the rendered text inside the matched element.

    ```typescript theme={null}
    const text = await locator.innerText();
    ```

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

    ## innerHtml()

    Return the HTML inside the matched element.

    ```typescript theme={null}
    const html = await locator.innerHtml();
    ```

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

    ## textContent()

    Return the text content of the matched element.

    ```typescript theme={null}
    const text = await locator.textContent();
    ```

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

    ## scrollTo()

    Scroll the matched element to a percentage of its range.

    ```typescript theme={null}
    await locator.scrollTo(50);
    ```

    <ParamField path="percent" type="number | string">
      A percentage from 0 to 100, optionally expressed as a percentage string.
    </ParamField>

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

    ## centroid()

    Return the center point of the matched element.

    ```typescript theme={null}
    const point = await locator.centroid();
    ```

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

      <ResponseField name="result.x" type="number">
        The horizontal center coordinate.
      </ResponseField>

      <ResponseField name="result.y" type="number">
        The vertical center coordinate.
      </ResponseField>
    </ResponseField>

    ## highlight()

    Temporarily highlight the matched element.

    ```typescript theme={null}
    await locator.highlight();
    ```

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

      <ParamField path="options.borderColor" type="RgbaColor" optional>
        The highlight border color.

        <ParamField path="options.borderColor.a" type="number" optional>
          The alpha channel.
        </ParamField>

        <ParamField path="options.borderColor.b" type="number">
          The blue channel.
        </ParamField>

        <ParamField path="options.borderColor.g" type="number">
          The green channel.
        </ParamField>

        <ParamField path="options.borderColor.r" type="number">
          The red channel.
        </ParamField>
      </ParamField>

      <ParamField path="options.contentColor" type="RgbaColor" optional>
        The highlight fill color.

        <ParamField path="options.contentColor.a" type="number" optional>
          The alpha channel.
        </ParamField>

        <ParamField path="options.contentColor.b" type="number">
          The blue channel.
        </ParamField>

        <ParamField path="options.contentColor.g" type="number">
          The green channel.
        </ParamField>

        <ParamField path="options.contentColor.r" type="number">
          The red channel.
        </ParamField>
      </ParamField>

      <ParamField path="options.durationMs" type="number" optional>
        How long to display the highlight.
      </ParamField>
    </ParamField>

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

    ## sendClickEvent()

    Dispatch a DOM click event on the matched element.

    ```typescript theme={null}
    await locator.sendClickEvent();
    ```

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

      <ParamField path="options.bubbles" type="boolean" optional>
        Whether the event bubbles.
      </ParamField>

      <ParamField path="options.cancelable" type="boolean" optional>
        Whether the event can be canceled.
      </ParamField>

      <ParamField path="options.composed" type="boolean" optional>
        Whether the event crosses shadow DOM boundaries.
      </ParamField>

      <ParamField path="options.detail" type="number" optional>
        The event-specific click detail.
      </ParamField>
    </ParamField>

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

    ## type()

    Type text into the matched element.

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

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

    <ParamField path="options" type="LocatorTypeOptions" 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>

    ## selectOption()

    Select one or more values in the matched select element.

    ```typescript theme={null}
    const values = await locator.selectOption("us");
    ```

    <ParamField path="values" type="string | string[]">
      The value or values to select.
    </ParamField>

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

    ## setInputFiles()

    Set one or more local files or in-memory payloads on the matched `<input type="file">`. The SDK resolves relative paths on the caller's machine. Pass an empty array to clear the selection.

    ```typescript theme={null}
    await page.locator('input[type="file"]').setInputFiles("./resume.pdf");
    ```

    <ParamField path="files" type="FileInput">
      Local file path(s) or in-memory payload(s) to upload. The SDK serializes each file in memory and limits it to 50 MiB.

      <ParamField path="files.name" type="string">
        The filename exposed to the page.
      </ParamField>

      <ParamField path="files.mimeType" type="string" optional>
        The file's MIME type.
      </ParamField>

      <ParamField path="files.buffer" type="ArrayBuffer | Uint8Array | string">
        The in-memory file content to upload. The SDK base64-encodes it for transport.
      </ParamField>

      <ParamField path="files.lastModified" type="number" optional>
        The file's last-modified time in Unix milliseconds.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="Promise<void>">
      Resolves after the files are attached.
    </ResponseField>

    ## first()

    Create a locator for the first matching element.

    ```typescript theme={null}
    const first = locator.first();
    ```

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

    ## nth()

    Create a locator for a matching element at a zero-based index.

    ```typescript theme={null}
    const third = locator.nth(2);
    ```

    <ParamField path="index" type="number">
      The zero-based match index.
    </ParamField>

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

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

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

    ## click()

    Click the element matched by this locator.

    ```python theme={null}
    await locator.click()
    ```

    <ParamField path="button" type="MouseButton | Literal['left', 'right', 'middle']" optional>
      The mouse button to use: `"left"`, `"middle"`, or `"right"`.
    </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 over the matched element.

    ```python theme={null}
    await locator.hover()
    ```

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

    ## fill()

    Replace the matched input's value.

    ```python theme={null}
    await locator.fill("Browserbase")
    ```

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

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

    ## count()

    Count the elements matched by this locator.

    ```python theme={null}
    count = await locator.count()
    ```

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

    ## is\_checked()

    Check whether the matched control is checked.

    ```python theme={null}
    checked = await locator.is_checked()
    ```

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

    ## input\_value()

    Return the current value of the matched input.

    ```python theme={null}
    value = await locator.input_value()
    ```

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

    ## is\_visible()

    Check whether the matched element is visible.

    ```python theme={null}
    visible = await locator.is_visible()
    ```

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

    ## inner\_text()

    Return the rendered text inside the matched element.

    ```python theme={null}
    text = await locator.inner_text()
    ```

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

    ## inner\_html()

    Return the HTML inside the matched element.

    ```python theme={null}
    html = await locator.inner_html()
    ```

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

    ## text\_content()

    Return the text content of the matched element.

    ```python theme={null}
    text = await locator.text_content()
    ```

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

    ## scroll\_to()

    Scroll the matched element to a percentage of its range.

    ```python theme={null}
    await locator.scroll_to(50)
    ```

    <ParamField path="percent" type="float | str">
      A percentage from 0 to 100, optionally expressed as a percentage string.
    </ParamField>

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

    ## centroid()

    Return the center point of the matched element.

    ```python theme={null}
    point = await locator.centroid()
    ```

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

      <ResponseField name="result.x" type="float">
        The horizontal center coordinate.
      </ResponseField>

      <ResponseField name="result.y" type="float">
        The vertical center coordinate.
      </ResponseField>
    </ResponseField>

    ## highlight()

    Temporarily highlight the matched element.

    ```python theme={null}
    await locator.highlight(duration_ms=1000)
    ```

    <ParamField path="duration_ms" type="int | None" optional>
      How long to display the highlight.
    </ParamField>

    <ParamField path="border_color" type="RgbaColor | None" optional>
      The highlight border color.

      <ParamField path="border_color.a" type="float" optional>
        The alpha channel.
      </ParamField>

      <ParamField path="border_color.b" type="float">
        The blue channel.
      </ParamField>

      <ParamField path="border_color.g" type="float">
        The green channel.
      </ParamField>

      <ParamField path="border_color.r" type="float">
        The red channel.
      </ParamField>
    </ParamField>

    <ParamField path="content_color" type="RgbaColor | None" optional>
      The highlight fill color.

      <ParamField path="content_color.a" type="float" optional>
        The alpha channel.
      </ParamField>

      <ParamField path="content_color.b" type="float">
        The blue channel.
      </ParamField>

      <ParamField path="content_color.g" type="float">
        The green channel.
      </ParamField>

      <ParamField path="content_color.r" type="float">
        The red channel.
      </ParamField>
    </ParamField>

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

    ## send\_click\_event()

    Dispatch a DOM click event on the matched element.

    ```python theme={null}
    await locator.send_click_event()
    ```

    <ParamField path="bubbles" type="bool | None" optional>
      Whether the event bubbles.
    </ParamField>

    <ParamField path="cancelable" type="bool | None" optional>
      Whether the event can be canceled.
    </ParamField>

    <ParamField path="composed" type="bool | None" optional>
      Whether the event crosses shadow DOM boundaries.
    </ParamField>

    <ParamField path="detail" type="float | None" optional>
      Event-specific click detail.
    </ParamField>

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

    ## type()

    Type text into the matched element.

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

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

    <ParamField path="delay" type="float | None" optional>
      Delay between keystrokes, in milliseconds.
    </ParamField>

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

    ## select\_option()

    Select one or more values in the matched select element.

    ```python theme={null}
    values = await locator.select_option("us")
    ```

    <ParamField path="values" type="str | Sequence[str]">
      The value or values to select.
    </ParamField>

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

    ## set\_input\_files()

    Set one or more local files or in-memory payloads on the matched `<input type="file">`. The SDK resolves relative paths on the caller's machine. Pass an empty sequence to clear the selection.

    ```python theme={null}
    await page.locator('input[type="file"]').set_input_files("./resume.pdf")
    ```

    <ParamField path="files" type="str | Path | FilePayload | Sequence[str | Path | FilePayload]">
      Local file path(s) or in-memory payload(s) to upload. The SDK serializes each file in memory and limits it to 50 MiB.

      <ParamField path="files.name" type="str">
        The filename exposed to the page.
      </ParamField>

      <ParamField path="files.mime_type" type="str" optional>
        The file's MIME type.
      </ParamField>

      <ParamField path="files.buffer" type="bytes | bytearray | memoryview | str">
        The in-memory file content to upload. The SDK base64-encodes it for transport.
      </ParamField>

      <ParamField path="files.last_modified" type="int" optional>
        The file's last-modified time in Unix milliseconds.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="None">
      Resolves after the files are attached.
    </ResponseField>

    ## first()

    Create a locator for the first matching element.

    ```python theme={null}
    first = locator.first()
    ```

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

    ## nth()

    Create a locator for a matching element at a zero-based index.

    ```python theme={null}
    third = locator.nth(2)
    ```

    <ParamField path="index" type="int">
      The zero-based match index.
    </ParamField>

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

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

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

    In Go the locator type is `*stagehand.PageLocator` (the wrapper named `Locator` in the TypeScript and Python SDKs). Every method takes a `context.Context` first, and methods with options accept a pointer options struct; pass `nil` for defaults.

    ## Click()

    Click the element matched by this locator.

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

    <ParamField path="options" type="*LocatorClickOptions" 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 over the matched element.

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

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

    ## Fill()

    Replace the matched input's value.

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

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

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

    ## Count()

    Count the elements matched by this locator.

    ```go theme={null}
    count, err := locator.Count(ctx)
    if err != nil {
        return err
    }
    fmt.Println(count)
    ```

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

    ## IsChecked()

    Check whether the matched control is checked.

    ```go theme={null}
    checked, err := locator.IsChecked(ctx)
    if err != nil {
        return err
    }
    fmt.Println(checked)
    ```

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

    ## InputValue()

    Return the current value of the matched input.

    ```go theme={null}
    value, err := locator.InputValue(ctx)
    if err != nil {
        return err
    }
    fmt.Println(value)
    ```

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

    ## IsVisible()

    Check whether the matched element is visible.

    ```go theme={null}
    visible, err := locator.IsVisible(ctx)
    if err != nil {
        return err
    }
    fmt.Println(visible)
    ```

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

    ## InnerText()

    Return the rendered text inside the matched element.

    ```go theme={null}
    text, err := locator.InnerText(ctx)
    if err != nil {
        return err
    }
    fmt.Println(text)
    ```

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

    ## InnerHTML()

    Return the HTML inside the matched element.

    ```go theme={null}
    html, err := locator.InnerHTML(ctx)
    if err != nil {
        return err
    }
    fmt.Println(html)
    ```

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

    ## TextContent()

    Return the text content of the matched element.

    ```go theme={null}
    text, err := locator.TextContent(ctx)
    if err != nil {
        return err
    }
    fmt.Println(text)
    ```

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

    ## ScrollTo()

    Scroll the matched element to a percentage of its range.

    ```go theme={null}
    if err := locator.ScrollTo(ctx, stagehand.NumericScrollPercent(50)); err != nil {
        return err
    }
    ```

    <ParamField path="percent" type="ScrollPercent">
      A percentage from 0 to 100. Construct it with `stagehand.NumericScrollPercent(50)`, or with `stagehand.NamedScrollPercent("50%")` for a percentage string.
    </ParamField>

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

    ## Centroid()

    Return the center point of the matched element.

    ```go theme={null}
    point, err := locator.Centroid(ctx)
    if err != nil {
        return err
    }
    fmt.Println(point.X, point.Y)
    ```

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

      <ResponseField name="result.X" type="float64">
        The horizontal center coordinate.
      </ResponseField>

      <ResponseField name="result.Y" type="float64">
        The vertical center coordinate.
      </ResponseField>
    </ResponseField>

    ## Highlight()

    Temporarily highlight the matched element.

    ```go theme={null}
    durationMs := 1000
    err := locator.Highlight(ctx, &stagehand.LocatorHighlightOptions{DurationMs: &durationMs})
    if err != nil {
        return err
    }
    ```

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

      <ParamField path="options.BorderColor" type="*RgbaColor" optional>
        The highlight border color.

        <ParamField path="options.BorderColor.A" type="*float64" optional>
          The alpha channel.
        </ParamField>

        <ParamField path="options.BorderColor.B" type="float64">
          The blue channel.
        </ParamField>

        <ParamField path="options.BorderColor.G" type="float64">
          The green channel.
        </ParamField>

        <ParamField path="options.BorderColor.R" type="float64">
          The red channel.
        </ParamField>
      </ParamField>

      <ParamField path="options.ContentColor" type="*RgbaColor" optional>
        The highlight fill color.

        <ParamField path="options.ContentColor.A" type="*float64" optional>
          The alpha channel.
        </ParamField>

        <ParamField path="options.ContentColor.B" type="float64">
          The blue channel.
        </ParamField>

        <ParamField path="options.ContentColor.G" type="float64">
          The green channel.
        </ParamField>

        <ParamField path="options.ContentColor.R" type="float64">
          The red channel.
        </ParamField>
      </ParamField>

      <ParamField path="options.DurationMs" type="*int" optional>
        How long to display the highlight.
      </ParamField>
    </ParamField>

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

    ## SendClickEvent()

    Dispatch a DOM click event on the matched element.

    ```go theme={null}
    if err := locator.SendClickEvent(ctx, nil); err != nil {
        return err
    }
    ```

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

      <ParamField path="options.Bubbles" type="*bool" optional>
        Whether the event bubbles.
      </ParamField>

      <ParamField path="options.Cancelable" type="*bool" optional>
        Whether the event can be canceled.
      </ParamField>

      <ParamField path="options.Composed" type="*bool" optional>
        Whether the event crosses shadow DOM boundaries.
      </ParamField>

      <ParamField path="options.Detail" type="*float64" optional>
        The event-specific click detail.
      </ParamField>
    </ParamField>

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

    ## Type()

    Type text into the matched element.

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

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

    <ParamField path="options" type="*LocatorTypeOptions" 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>

    ## SelectOption()

    Select one or more values in the matched select element.

    ```go theme={null}
    values, err := locator.SelectOption(ctx, stagehand.StringList{"us"})
    if err != nil {
        return err
    }
    fmt.Println(values)
    ```

    <ParamField path="values" type="StringList">
      The value or values to select. `StringList` is a `[]string`.
    </ParamField>

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

    ## SetInputFiles()

    Set one or more local files or in-memory payloads on the matched `<input type="file">`. The SDK resolves relative paths on the caller's machine. Call it without files to clear the selection.

    ```go theme={null}
    err := page.Locator(`input[type="file"]`).SetInputFiles(ctx, stagehand.FilePath("./resume.pdf"))
    if err != nil {
        return err
    }
    ```

    <ParamField path="files" type="...FileInput">
      Local file path(s) or in-memory payload(s) to upload. Construct each with `stagehand.FilePath(path)` or `stagehand.FileData(name, mimeType, buffer)`. The SDK serializes each file in memory and limits it to 50 MiB.

      <ParamField path="files.Path" type="string">
        A path on the SDK caller's filesystem. Cannot be combined with the payload fields.
      </ParamField>

      <ParamField path="files.Name" type="string">
        The filename exposed to the page.
      </ParamField>

      <ParamField path="files.MIMEType" type="string" optional>
        The file's MIME type.
      </ParamField>

      <ParamField path="files.Buffer" type="[]byte">
        The in-memory file content to upload. The SDK base64-encodes it for transport.
      </ParamField>

      <ParamField path="files.LastModified" type="*int64" optional>
        The file's last-modified time in Unix milliseconds.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="error">
      Returns `nil` after the files are attached.
    </ResponseField>

    ## First()

    Create a locator for the first matching element.

    ```go theme={null}
    first := locator.First()
    if err := first.Click(ctx, nil); err != nil {
        return err
    }
    ```

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

    ## Nth()

    Create a locator for a matching element at a zero-based index. Returns an error when the index is negative.

    ```go theme={null}
    third, err := locator.Nth(2)
    if err != nil {
        return err
    }
    if err := third.Click(ctx, nil); err != nil {
        return err
    }
    ```

    <ParamField path="index" type="int">
      The zero-based match index.
    </ParamField>

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