Skip to main content
Glama
cloudflare

Cloudflare Playwright MCP

Official
by cloudflare

browser_select_option

Automatically select dropdown options in web browsers using Playwright for efficient testing. Specify target elements and values to streamline interaction and validation workflows.

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 core implementation of the 'browser_select_option' tool. It defines the tool schema and the handler function that generates Playwright code to select options in a dropdown and executes the action on the locator derived from the page snapshot.
    const selectOption = defineTool({ capability: 'core', schema: { name: 'browser_select_option', title: 'Select option', description: 'Select an option in a dropdown', inputSchema: selectOptionSchema, type: 'destructive', }, 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, }; }, });
  • Zod schema definition for the input parameters of the browser_select_option tool, extending the shared elementSchema with 'values' array.
    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.'), });
  • src/tools.ts:35-50 (registration)
    Registration of the snapshot tools array, which includes the browser_select_option tool from the snapshot module via array spread.
    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), ];
  • src/tools.ts:26-26 (registration)
    Import of the snapshot module containing the browser_select_option tool definition.
    import snapshot from './tools/snapshot.js';

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

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