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
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector for the element | |
| values | Yes | Option values to select | |
| timeout | No | Timeout in milliseconds | |
| tabId | No | Tab ID to operate on (uses active tab if not specified) |
Implementation Reference
- dist/tools/interaction.js:70-89 (handler)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))); } });
- dist/schemas.js:56-61 (schema)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);