Skip to content

selectOptionFromDropdown is chosen given a non-select dropdown #884

@Corb3nik

Description

@Corb3nik

Hi team,

When attempting to select an option from a dropdown that does not use the select element, I am faced with the following error.

2025-07-15 10:49:27.267 -0400] INFO: starting observation
    category: "observation"
    instruction: "Find the most relevant element to perform an action on given the following action: - Select the \"Numbers\" type. \n  Provide an action for this element such as click, fill, type, press, scrollTo, nextChunk, prevChunk, selectOptionFromDropdown, or any other playwright locator method. Remember that to users, buttons and links look the same in most cases.\n  If the action is completely unrelated to a potential action to be taken on the page, return an empty array. \n  ONLY return one action. If multiple actions are relevant, return the most relevant one. \n  If the user is asking to scroll to a position on the page, e.g., 'halfway' or 0.75, etc, you must return the argument formatted as the correct percentage, e.g., '50%' or '75%', etc.\n  If the user is asking to scroll to the next chunk/previous chunk, choose the nextChunk/prevChunk method. No arguments are required here.\n  If the action implies a key press, e.g., 'press enter', 'press a', 'press space', etc., always choose the press method with the appropriate key as argument — e.g. 'a', 'Enter', 'Space'. Do not choose a click action on an on-screen keyboard. Capitalize the first character like 'Enter', 'Tab', 'Escape' only for special keys.\n  If the action implies choosing an option from a dropdown, AND the corresponding element is a 'select' element, choose the selectOptionFromDropdown method. The argument should be the text of the option to select.\n  If the action implies choosing an option from a dropdown, and the corresponding element is NOT a 'select' element, choose the click method."
[2025-07-15 10:49:27.771 -0400] INFO: Getting accessibility tree data
    category: "observation"
[2025-07-15 10:49:27.839 -0400] INFO: got accessibility tree in 3 ms
    category: "observation"
Step failed: - Select the "Numbers" type
[2025-07-15 10:49:29.337 -0400] INFO: Getting xpath for element
    category: "observation"
    elementId: "0-4106"
[2025-07-15 10:49:29.337 -0400] INFO: found elements
    category: "observation"
    elements: [
      {
        "description": "combobox: Type - Allows selection of the type of payload, including 'Numbers'.",
        "method": "selectOptionFromDropdown",
        "arguments": [
          "Numbers"
        ],
        "selector": "xpath=/html[1]/body[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[4]/div[1]/div[1]/div[1]/div[3]/div[1]/div[2]/div[1]/div[1]/div[2]/div[1]/div[3]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[3]/div[1]/div[1]/span[1]"
      }
    ]
[2025-07-15 10:49:29.337 -0400] INFO: Performing act from an ObserveResult
    category: "action"
    observeResult: {
      "description": "combobox: Type - Allows selection of the type of payload, including 'Numbers'.",
      "method": "selectOptionFromDropdown",
      "arguments": [
        "Numbers"
      ],
      "selector": "xpath=/html[1]/body[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[4]/div[1]/div[1]/div[1]/div[3]/div[1]/div[2]/div[1]/div[1]/div[2]/div[1]/div[3]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[3]/div[1]/div[1]/span[1]"
    }
[2025-07-15 10:49:29.347 -0400] ERROR: error selecting option
    category: "action"
    trace: "locator.selectOption: Error: Element is not a <select> element\nCall log:\n\u001b[2m  - waiting for locator('xpath=/html[1]/body[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[4]/div[1]/div[1]/div[1]/div[3]/div[1]/div[2]/div[1]/div[1]/div[2]/div[1]/div[3]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[3]/div[1]/div[1]/span[1]').first()\u001b[22m\n\u001b[2m    - locator resolved to <span tabindex=\"0\" role=\"combobox\" aria-expanded=\"false\" aria-disabled=\"false\" aria-haspopup=\"listbox\" data-pc-section=\"label\" aria-label=\"Hosted File\" aria-controls=\"v-7_list\" class=\"leading-[normal] block flex-auto bg-transparent border-0 text-surface-800 dark:text-white/80 placeholder:text-surface-400 dark:placeholder:text-surface-500 w-[1%] py-2 pl-3 rounded-none transition duration-200 focus:outline-none focus:shadow-none relative cursor-pointer overflow-hidden overflow-ellipsis whitespace-nowr…>Hosted File</span>\u001b[22m\n\u001b[2m  - attempting select option action\u001b[22m\n\u001b[2m    - waiting for element to be visible and enabled\u001b[22m\n\n    at /Users/corb3nik/Projects/caido/.../node_modules/.pnpm/@browserbasehq+stagehand@2.4.1_deepmerge@4.3.1_dotenv@16.4.7_react@19.1.0_zod@3.25.67/node_modules/@browserbasehq/stagehand/dist/index.js:1196:21\n    at /Users/corb3nik/Projects/caido/.../node_modules/.pnpm/@browserbasehq+stagehand@2.4.1_deepmerge@4.3.1_dotenv@16.4.7_react@19.1.0_zod@3.25.67/node_modules/@browserbasehq/stagehand/dist/index.js:79:61\n    at __async (/Users/corb3nik/Projects/caido/hackbot/node_modules/.pnpm/@browserbasehq+stagehand@2.4.1_deepmerge@4.3.1_dotenv@16.4.7_react@19.1.0_zod@3.25.67/node_modules/@browserbasehq/stagehand/dist/index.js:63:10)\n    at selectOption (/Users/corb3nik/Projects/caido/hackbot/node_modules/.pnpm/@browserbasehq+stagehand@2.4.1_deepmerge@4.3.1_dotenv@16.4.7_react@19.1.0_zod@3.25.67/node_modules/@browserbasehq/stagehand/dist/index.js:1191:10)\n    at StagehandActHandler.<anonymous> (/Users/corb3nik/Projects/caido/hackbot/node_modules/.pnpm/@browserbasehq+stagehand@2.4.1_deepmerge@4.3.1_dotenv@16.4.7_react@19.1.0_zod@3.25.67/node_modules/@browserbasehq/stagehand/dist/index.js:1601:17)\n    at /Users/corb3nik/Projects/caido/hackbot/node_modules/.pnpm/@browserbasehq+stagehand@2.4.1_deepmerge@4.3.1_dotenv@16.4.7_react@19.1.0_zod@3.25.67/node_modules/@browserbasehq/stagehand/dist/index.js:79:61\n    at __async (/Users/corb3nik/Projects/caido/hackbot/node_modules/.pnpm/@browserbasehq+stagehand@2.4.1_deepmerge@4.3.1_dotenv@16.4.7_react@19.1.0_zod@3.25.67/node_modules/@browserbasehq/stagehand/dist/index.js:63:10)\n    at StagehandActHandler._performPlaywrightMethod (/Users/corb3nik/Projects/caido/hackbot/node_modules/.pnpm/@browserbasehq+stagehand@2.4.1_deepmerge@4.3.1_dotenv@16.4.7_react@19.1.0_zod@3.25.67/node_modules/@browserbasehq/stagehand/dist/index.js:1576:12)\n    at StagehandActHandler.<anonymous> (/Users/corb3nik/Projects/caido/hackbot/node_modules/.pnpm/@browserbasehq+stagehand@2.4.1_deepmerge@4.3.1_dotenv@16.4.7_react@19.1.0_zod@3.25.67/node_modules/@browserbasehq/stagehand/dist/index.js:1431:20)\n    at /Users/corb3nik/Projects/caido/hackbot/node_modules/.pnpm/@browserbasehq+stagehand@2.4.1_deepmerge@4.3.1_dotenv@16.4.7_react@19.1.0_zod@3.25.67/node_modules/@browserbasehq/stagehand/dist/index.js:79:61\n    at __async (/Users/corb3nik/Projects/caido/hackbot/node_modules/.pnpm/@browserbasehq+stagehand@2.4.1_deepmerge@4.3.1_dotenv@16.4.7_react@19.1.0_zod@3.25.67/node_modules/@browserbasehq/stagehand/dist/index.js:63:10)\n    at StagehandActHandler.actFromObserveResult (/Users/corb3nik/Projects/caido/hackbot/node_modules/.pnpm/@browserbasehq+stagehand@2.4.1_deepmerge@4.3.1_dotenv@16.4.7_react@19.1.0_zod@3.25.67/node_modules/@browserbasehq/stagehand/dist/index.js:1392:12)\n    at StagehandActHandler.<anonymous> (/Users/corb3nik/Projects/caido/hackbot/node_modules/.pnpm/@browserbasehq+stagehand@2.4.1_deepmerge@4.3.1_dotenv@16.4.7_react@19.1.0_zod@3.25.67/node_modules/@browserbasehq/stagehand/dist/index.js:1552:21)\n    at fulfilled (/Users/corb3nik/Projects/caido/hackbot/node_modules/.pnpm/@browserbasehq+stagehand@2.4.1_deepmerge@4.3.1_dotenv@16.4.7_react@19.1.0_zod@3.25.67/node_modules/@browserbasehq/stagehand/dist/index.js:66:24)"
    xpath: "/html[1]/body[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[4]/div[1]/div[1]/div[1]/div[3]/div[1]/div[2]/div[1]/div[1]/div[2]/div[1]/div[3]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[3]/div[1]/div[1]/span[1]"
    error: "locator.selectOption: Error: Element is not a <select> element\nCall log:\n\u001b[2m  - waiting for locator('xpath=/html[1]/body[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[4]/div[1]/div[1]/div[1]/div[3]/div[1]/div[2]/div[1]/div[1]/div[2]/div[1]/div[3]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[3]/div[1]/div[1]/span[1]').first()\u001b[22m\n\u001b[2m    - locator resolved to <span tabindex=\"0\" role=\"combobox\" aria-expanded=\"false\" aria-disabled=\"false\" aria-haspopup=\"listbox\" data-pc-section=\"label\" aria-label=\"Hosted File\" aria-controls=\"v-7_list\" class=\"leading-[normal] block flex-auto bg-transparent border-0 text-surface-800 dark:text-white/80 placeholder:text-surface-400 dark:placeholder:text-surface-500 w-[1%] py-2 pl-3 rounded-none transition duration-200 focus:outline-none focus:shadow-none relative cursor-pointer overflow-hidden overflow-ellipsis whitespace-nowr…>Hosted File</span>\u001b[22m\n\u001b[2m  - attempting select option action\u001b[22m\n\u001b[2m    - waiting for element to be visible and enabled\u001b[22m\n"

In the stack trace above, the chosen selector is a span:

xpath=/html[1]/body[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[4]/div[1]/div[1]/div[1]/div[3]/div[1]/div[2]/div[1]/div[1]/div[2]/div[1]/div[3]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[3]/div[1]/div[1]/span[1])

I would expect the resulting action to use the "click" method here and not error out.

This is my first issue in this repo, please let me know if I'm misunderstanding Stagehand's role in this and if this is something that should be fixed on my end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions