browser_select_dropdown_by_text
Select dropdown options by visible text in web automation. Use this tool to interact with dropdown menus by specifying the exact text of the option you want to select.
Instructions
Select dropdown by visible text
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| by | Yes | Locator strategy to find element | |
| text | Yes | Visible text of the option to select | |
| timeout | No | Maximum time to wait for element in milliseconds | |
| value | Yes | Value for the locator strategy |
Implementation Reference
- src/services/actionService.ts:46-51 (handler)Core handler logic for selecting a dropdown option by visible text using Selenium WebDriver's Select class.async selectDropdownByText(params: LocatorParams & { text: 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.selectByVisibleText(params.text); }
- src/tools/actionTools.ts:142-168 (registration)MCP tool registration for 'browser_select_dropdown_by_text', including input schema and wrapper handler that delegates to ActionService.server.tool( 'browser_select_dropdown_by_text', 'Select dropdown by visible text', { ...locatorSchema, text: z.string().describe('Visible text of the option to select'), }, async ({ by, value, text, timeout = 15000 }) => { try { const driver = stateManager.getDriver(); const actionService = new ActionService(driver); await actionService.selectDropdownByText({ by, value, text, timeout }); return { content: [{ type: 'text', text: `Selected dropdown option by text: ${text}` }], }; } catch (e) { return { content: [ { type: 'text', text: `Error selecting dropdown option by text: ${(e as Error).message}`, }, ], }; } } );
- src/types/index.ts:29-35 (schema)Base locatorSchema used in the tool's input schema for specifying element locator (by, value, timeout).export const locatorSchema = { by: z .enum(['id', 'css', 'xpath', 'name', 'tag', 'class', 'link', 'partialLink']) .describe('Locator strategy to find element'), value: z.string().describe('Value for the locator strategy'), timeout: z.number().optional().describe('Maximum time to wait for element in milliseconds'), };