playwright_select
Automate selection of elements with Select tags in web pages using CSS selectors and specified values, enabling precise browser interaction within Playwright MCP Server.
Instructions
Select an element on the page with Select tag
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector for element to select | |
| value | Yes | Value to select |
Implementation Reference
- src/toolsHandler.ts:224-247 (handler)Handler for the 'playwright_select' tool. Waits for the selector, selects the specified value using Playwright's selectOption, and returns success or error message.case "playwright_select": try { await page!.waitForSelector(args.selector); await page!.selectOption(args.selector, args.value); return { toolResult: { content: [{ type: "text", text: `Selected ${args.selector} with: ${args.value}`, }], isError: false, }, }; } catch (error) { return { toolResult: { content: [{ type: "text", text: `Failed to select ${args.selector}: ${(error as Error).message}`, }], isError: true, }, }; }
- src/tools.ts:56-67 (schema)Tool schema definition for 'playwright_select', including name, description, and input schema requiring selector and value.{ name: "playwright_select", description: "Select an element on the page with Select tag", inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector for element to select" }, value: { type: "string", description: "Value to select" }, }, required: ["selector", "value"], }, },
- src/index.ts:22-23 (registration)Registration of all tools including 'playwright_select' by calling createToolDefinitions() which includes the tool schema.// Create tool definitions const TOOLS = createToolDefinitions();
- src/tools.ts:152-160 (helper)BROWSER_TOOLS array includes 'playwright_select' to determine if browser launch is required for this tool.export const BROWSER_TOOLS = [ "playwright_navigate", "playwright_screenshot", "playwright_click", "playwright_fill", "playwright_select", "playwright_hover", "playwright_evaluate" ];