Skip to main content
Glama

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
NameRequiredDescriptionDefault
byYesLocator strategy to find element
timeoutNoMaximum time to wait for element in milliseconds
valueYesValue of the option to select

Implementation Reference

  • MCP tool handler function for browser_select_dropdown_by_value, which instantiates ActionService and calls selectDropdownByValue
    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}`, }, ], }; } }
  • Core helper method implementing the dropdown selection by value using Selenium WebDriver's Select class
    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); }
  • Registration of the tool with MCP server in registerActionTools function, including description, input schema (extending locatorSchema), and handler
    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}`, }, ], }; } } );
  • Tool-specific input schema using Zod, extending shared locatorSchema with option value
    { ...locatorSchema, value: z.string().describe('Value of the option to select'), },
  • Shared locatorSchema used in the tool schema (definition block starts here)
    export const locatorSchema = {

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