browser_select_option
Select specified values from a dropdown element on a web page using structured accessibility snapshots, enabling precise interaction without visual models.
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:201-217 (handler)The handle function implements the browser_select_option tool by generating code and an action to select specified values in a dropdown element using Playwright locators.handle: async (context, params) => { const snapshot = context.currentTabOrDie().snapshotOrDie(); const locator = snapshot.refLocator(params); const code = [ `// Select options [${params.values.join(', ')}] in ${params.element}`, `await page.${await generateLocator(locator)}.selectOption(${javascript.formatObject(params.values)});` ]; return { code, action: () => locator.selectOption(params.values).then(() => {}), captureSnapshot: true, waitForNetwork: true, }; }, });
- src/tools/snapshot.ts:187-199 (schema)Defines the Zod input schema (extending elementSchema with 'values' array) and the tool schema including name 'browser_select_option'.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.'), }); const selectOption = defineTool({ capability: 'core', schema: { name: 'browser_select_option', title: 'Select option', description: 'Select an option in a dropdown', inputSchema: selectOptionSchema, type: 'destructive', },
- src/tools/snapshot.ts:219-226 (registration)Registers the selectOption tool (browser_select_option) by including it in the default export array of tools from this module.export default [ snapshot, click, drag, hover, type, selectOption, ];