Skip to main content
Glama

browser_select_dropdown_by_text

Selects a dropdown option by its visible text in web automation. Use this tool to interact with dropdown menus by specifying the element locator and the text to select.

Instructions

Select dropdown by visible text

Input Schema

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

Implementation Reference

  • Core implementation of the dropdown selection by visible text using Selenium's Select class. Locates the dropdown element and selects the option matching the provided text.
    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); }
  • Registers the MCP tool 'browser_select_dropdown_by_text' with input schema (locator + text) and a 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}`, }, ], }; } } );
  • Zod schema defining the locator parameters (by, value, timeout) extended in the tool 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