Skip to main content
Glama

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

Implementation Reference

  • 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); }
  • 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}`, }, ], }; } } );
  • 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'), };

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