Skip to main content
Glama

browser_select_option

Select options in dropdown menus during browser automation. Specify element references and values to interact with web page select elements programmatically.

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

  • The handler function that implements the browser_select_option tool. It resolves the element locator from the page snapshot, generates the corresponding code snippet, and executes the selectOption action using Playwright's locator API.
    handle: async (context, params) => { const snapshot = context.currentTabOrDie().snapshotOrDie(); const locator = snapshot.refLocator(params); const code = [ `// Select options [${params.values.join(', ')}] in ${params.element}`, `await page.${await generateLocator(locator)}.selectOption(${javascript.formatObject(params.values)});` ]; return { code, action: () => locator.selectOption(params.values).then(() => {}), captureSnapshot: true, waitForNetwork: true, }; },
  • Defines the input schema using Zod, extending the base elementSchema with 'values' array, and the tool's metadata schema including the name 'browser_select_option'.
    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.'), }); const selectOption = defineTool({ capability: 'core', schema: { name: 'browser_select_option', title: 'Select option', description: 'Select an option in a dropdown', inputSchema: selectOptionSchema, type: 'destructive', },
  • Registers and exports the selectOption tool (browser_select_option) within the snapshot module's default export array.
    export default [ snapshot, click, drag, hover, type, selectOption, ];
  • src/tools.ts:35-50 (registration)
    Includes the snapshot module (containing browser_select_option) in the main snapshotTools array for global tool registration.
    export const snapshotTools: Tool<any>[] = [ ...common(true), ...console, ...dialogs(true), ...files(true), ...install, ...keyboard(true), ...navigate(true), ...network, ...pdf, ...screenshot, ...snapshot, ...tabs(true), ...testing, ...wait(true), ];

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/Angeluis001/playwright-mcp'

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