browser_select_option
Select a specific option from dropdown elements in web browsers using element selectors and values to automate form interactions or UI testing.
Instructions
Select an option from a dropdown
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| instanceId | Yes | Instance ID | |
| selector | Yes | Element selector | |
| value | Yes | Value to select | |
| timeout | No | Timeout in milliseconds |
Implementation Reference
- src/tools.ts:769-789 (handler)The main handler function that executes the browser_select_option tool by calling Playwright's page.selectOption method on the specified selector with the given value.private async selectOption(instanceId: string, selector: string, value: string, timeout: number): Promise<ToolResult> { const instance = this.browserManager.getInstance(instanceId); if (!instance) { return { success: false, error: `Instance ${instanceId} not found` }; } try { await instance.page.selectOption(selector, value, { timeout }); return { success: true, data: { selector, value, selected: true }, instanceId }; } catch (error) { return { success: false, error: `Select option failed: ${error instanceof Error ? error.message : error}`, instanceId }; } }
- src/tools.ts:265-289 (schema)The input schema and metadata (name, description) for the browser_select_option tool, used for validation and MCP registration.name: 'browser_select_option', description: 'Select an option from a dropdown', inputSchema: { type: 'object', properties: { instanceId: { type: 'string', description: 'Instance ID' }, selector: { type: 'string', description: 'Element selector', }, value: { type: 'string', description: 'Value to select', }, timeout: { type: 'number', description: 'Timeout in milliseconds', default: 30000 } }, required: ['instanceId', 'selector', 'value'] }
- src/tools.ts:550-552 (registration)The dispatch case in the executeTools method that routes calls to the selectOption handler.case 'browser_select_option': return await this.selectOption(args.instanceId, args.selector, args.value, args.timeout || 30000);