browser_select_option
Select one or multiple options from a dropdown on a webpage using structured accessibility snapshots. Define the target element and values to interact with the dropdown efficiently.
Instructions
Select an option in a dropdown
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| element | Yes | Human-readable element description used to obtain permission to interact with the element | |
| ref | Yes | Exact target element reference from the page snapshot | |
| values | Yes | Array of values to select in the dropdown. This can be a single value or multiple values. |
Implementation Reference
- src/tools/snapshot.ts:150-160 (handler)Handler function that executes the browser_select_option tool: locates the dropdown element using refLocator, generates code to select the specified options using Playwright's selectOption, adds it to the response, and waits for completion by executing the action.handle: async (tab, params, response) => { response.setIncludeSnapshot(); const locator = await tab.refLocator(params); response.addCode(`// Select options [${params.values.join(', ')}] in ${params.element}`); response.addCode(`await page.${await generateLocator(locator)}.selectOption(${javascript.formatObject(params.values)});`); await tab.waitForCompletion(async () => { await locator.selectOption(params.values); }); },
- src/tools/snapshot.ts:142-148 (schema)Main schema definition for the browser_select_option tool, specifying name, title, description, input schema reference, and type.schema: { name: 'browser_select_option', title: 'Select option', description: 'Select an option in a dropdown', inputSchema: selectOptionSchema, type: 'destructive', },
- src/tools/snapshot.ts:136-138 (schema)Input schema for browser_select_option extending elementSchema with 'values' array of strings.const selectOptionSchema = elementSchema.extend({ values: z.array(z.string()).describe('Array of values to select in the dropdown. This can be a single value or multiple values.'), });
- src/tools/snapshot.ts:163-169 (registration)The browser_select_option tool (selectOption) is included in the default export array for registration in the MCP tools module.export default [ snapshot, click, drag, hover, selectOption, ];