browser_select_dropdown_by_value
Select specific options from dropdown menus in web browsers using locator strategies and option values for automated testing and interaction.
Instructions
Select dropdown by value
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| by | Yes | Locator strategy to find element | |
| timeout | No | Maximum time to wait for element in milliseconds | |
| value | Yes | Value of the option to select |
Implementation Reference
- src/tools/actionTools.ts:177-200 (handler)MCP tool handler function for browser_select_dropdown_by_value, which instantiates ActionService and calls selectDropdownByValueasync ({ by, value, timeout = 15000 }) => { try { const driver = stateManager.getDriver(); const actionService = new ActionService(driver); await actionService.selectDropdownByValue({ by, value, timeout }); return { content: [ { type: 'text', text: `Selected dropdown option by value: ${value}`, }, ], }; } catch (e) { return { content: [ { type: 'text', text: `Error selecting dropdown option by value: ${(e as Error).message}`, }, ], }; } }
- src/services/actionService.ts:53-58 (helper)Core helper method implementing the dropdown selection by value using Selenium WebDriver's Select classasync selectDropdownByValue(params: LocatorParams & { value: string }): Promise<void> { const locator = LocatorFactory.createLocator(params.by, params.value); const selectElement = await this.driver.wait(until.elementLocated(locator), params.timeout || 15000); const select = new Select(selectElement); await select.selectByValue(params.value); }
- src/tools/actionTools.ts:170-201 (registration)Registration of the tool with MCP server in registerActionTools function, including description, input schema (extending locatorSchema), and handlerserver.tool( 'browser_select_dropdown_by_value', 'Select dropdown by value', { ...locatorSchema, value: z.string().describe('Value of the option to select'), }, async ({ by, value, timeout = 15000 }) => { try { const driver = stateManager.getDriver(); const actionService = new ActionService(driver); await actionService.selectDropdownByValue({ by, value, timeout }); return { content: [ { type: 'text', text: `Selected dropdown option by value: ${value}`, }, ], }; } catch (e) { return { content: [ { type: 'text', text: `Error selecting dropdown option by value: ${(e as Error).message}`, }, ], }; } } );
- src/tools/actionTools.ts:173-176 (schema)Tool-specific input schema using Zod, extending shared locatorSchema with option value{ ...locatorSchema, value: z.string().describe('Value of the option to select'), },
- src/types/index.ts:29-29 (schema)Shared locatorSchema used in the tool schema (definition block starts here)export const locatorSchema = {