Skip to main content
Glama

browser_select_dropdown_by_value

Selects a specific option from a dropdown menu in a web browser using its value attribute. This tool helps automate form filling and UI testing by targeting dropdown elements with precision.

Instructions

Select dropdown by value

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
byYesLocator strategy to find element
valueYesValue of the option to select
timeoutNoMaximum time to wait for element in milliseconds

Implementation Reference

  • Core handler function that locates the dropdown element using LocatorFactory, waits for it to be present, instantiates Selenium's Select class, and selects the option by its value attribute.
    async 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); }
  • Registers the MCP tool 'browser_select_dropdown_by_value' using McpServer.tool(), defines input schema extending locatorSchema (with value overridden for option value), and provides a thin async handler that instantiates ActionService and delegates execution.
    server.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}`, }, ], }; } }
  • Zod schema defining the base locator parameters (by, value, optional timeout), which is spread into the tool's input schema.
    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'), };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pshivapr/selenium-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server