Skip to main content
Glama

select

Select options from dropdown or select elements on web pages using CSS selectors and specified values for browser automation tasks.

Instructions

Select option(s) from a dropdown/select element

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesCSS selector for the element
valuesYesOption values to select
timeoutNoTimeout in milliseconds
tabIdNoTab ID to operate on (uses active tab if not specified)

Implementation Reference

  • Handler for the 'select' tool: waits for the selector, then uses page.select to choose the specified option values from a dropdown.
    // Select dropdown option server.tool('select', 'Select option(s) from a dropdown/select element', selectSchema.shape, async ({ selector, values, timeout, tabId }) => { const pageResult = await getPageForOperation(tabId); if (!pageResult.success) { return handleResult(pageResult); } const page = pageResult.data; const timeoutMs = timeout ?? getDefaultTimeout(); try { await page.waitForSelector(selector, { timeout: timeoutMs }); const selected = await page.select(selector, ...values); return handleResult(ok({ selected, selector })); } catch (error) { if (error instanceof Error && error.message.includes('waiting for selector')) { return handleResult(err(selectorNotFound(selector))); } return handleResult(err(normalizeError(error))); } });
  • Input schema for the 'select' tool using Zod, defining selector, values (array of strings), optional timeout and tabId.
    export const selectSchema = z.object({ selector: selectorSchema, values: z.array(z.string()).min(1).describe('Option values to select'), timeout: timeoutSchema, tabId: tabIdSchema, });
  • dist/server.js:22-22 (registration)
    Registers the interaction tools group, which includes the 'select' tool.
    registerInteractionTools(server);

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/andytango/puppeteer-mcp'

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