Skip to main content
Glama

browser_select_option

Select one or multiple options from a dropdown on a webpage using structured accessibility snapshots. Define the target element and values to interact with the dropdown efficiently.

Instructions

Select an option in a dropdown

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
elementYesHuman-readable element description used to obtain permission to interact with the element
refYesExact target element reference from the page snapshot
valuesYesArray of values to select in the dropdown. This can be a single value or multiple values.

Implementation Reference

  • Handler function that executes the browser_select_option tool: locates the dropdown element using refLocator, generates code to select the specified options using Playwright's selectOption, adds it to the response, and waits for completion by executing the action.
    handle: async (tab, params, response) => { response.setIncludeSnapshot(); const locator = await tab.refLocator(params); response.addCode(`// Select options [${params.values.join(', ')}] in ${params.element}`); response.addCode(`await page.${await generateLocator(locator)}.selectOption(${javascript.formatObject(params.values)});`); await tab.waitForCompletion(async () => { await locator.selectOption(params.values); }); },
  • Main schema definition for the browser_select_option tool, specifying name, title, description, input schema reference, and type.
    schema: { name: 'browser_select_option', title: 'Select option', description: 'Select an option in a dropdown', inputSchema: selectOptionSchema, type: 'destructive', },
  • Input schema for browser_select_option extending elementSchema with 'values' array of strings.
    const selectOptionSchema = elementSchema.extend({ values: z.array(z.string()).describe('Array of values to select in the dropdown. This can be a single value or multiple values.'), });
  • The browser_select_option tool (selectOption) is included in the default export array for registration in the MCP tools module.
    export default [ snapshot, click, drag, hover, selectOption, ];

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/nzjami/mcpPlaywright'

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