browser_select_option
Automates the selection of dropdown options in web accessibility scans, ensuring accurate interaction with specific elements for WCAG compliance testing. Ideal for precise dropdown value validation.
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:203-215 (schema)Defines the Zod input schema and tool metadata (name, title, description, type) for the browser_select_option tool. It extends the shared elementSchema with a 'values' array parameter.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 = defineTabTool({ 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:217-227 (handler)The core handler function that executes the tool. It resolves the element locator from the provided ref, generates equivalent Playwright code for the response, includes a page snapshot, and performs the selectOption action on the locator using the provided values.handle: async (tab, params, response) => { response.setIncludeSnapshot(); const locator = await tab.refLocator(params); response.addCode(`await page.${await generateLocator(locator)}.selectOption(${javascript.formatObject(params.values)});`); await tab.waitForCompletion(async () => { await locator.selectOption(params.values); }); }, });
- src/browserServerBackend.ts:41-42 (registration)Registers the browser tools (including browser_select_option) by initializing the tools list via filteredTools(config) in the BrowserServerBackend, which provides them to the MCP server via listTools() and callTool().this._tools = filteredTools(config); }
- src/tools.ts:38-56 (registration)Aggregates all browser tool modules, including snapshot.ts which defines browser_select_option, into the allTools array. filteredTools filters this list based on config for the backend.export const allTools: Tool<any>[] = [ ...common, ...console, ...dialogs, ...evaluate, ...files, ...form, ...install, ...keyboard, ...navigate, ...network, ...mouse, ...pdf, ...screenshot, ...snapshot, ...tabs, ...wait, ...verify, ];