playwright_hover
Simulate mouse hover interactions on web elements using CSS selectors for testing or automation scenarios.
Instructions
Hover an element on the page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector for element to hover |
Implementation Reference
- src/toolsHandler.ts:251-270 (handler)The switch case in handleToolCall function that implements the playwright_hover tool. It waits for the selector, hovers the element using page.hover, and returns success or error message.case "playwright_hover": try { await page!.waitForSelector(args.selector); await page!.hover(args.selector); return { content: [{ type: "text", text: `Hovered ${args.selector}`, }], isError: false, }; } catch (error) { return { content: [{ type: "text", text: `Failed to hover ${args.selector}: ${(error as Error).message}`, }], isError: true, }; }
- src/tools.ts:72-82 (schema)The tool schema definition in createToolDefinitions(), specifying name, description, and input schema requiring a 'selector' property.{ name: "playwright_hover", description: "Hover an element on the page", inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector for element to hover" }, }, required: ["selector"], }, },
- src/requestHandler.ts:59-62 (registration)Registration of the listTools request handler, which returns the array of all tools including playwright_hover.// List tools handler server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: tools, }));
- src/requestHandler.ts:65-67 (registration)Registration of the callTool request handler, which dispatches to the specific handler based on tool name.server.setRequestHandler(CallToolRequestSchema, async (request) => handleToolCall(request.params.name, request.params.arguments ?? {}, server) );
- src/index.ts:22-26 (registration)Where the tools are created via createToolDefinitions() and passed to setupRequestHandlers for registration on the MCP server.// Create tool definitions const TOOLS = createToolDefinitions(); // Setup request handlers setupRequestHandlers(server, TOOLS);