playwright_hover
Simulate hovering over a web element using a CSS selector with the MCP Browser Automation Server, enabling precise interaction for automated browser tasks.
Instructions
Hover an element on the page
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector for element to hover |
Input Schema (JSON Schema)
{
"properties": {
"selector": {
"description": "CSS selector for element to hover",
"type": "string"
}
},
"required": [
"selector"
],
"type": "object"
}
Implementation Reference
- src/toolsHandler.ts:249-272 (handler)Handler implementation for the 'playwright_hover' tool. It waits for the specified selector to appear on the page and then hovers over it using Playwright's page.hover method. Returns a success message or an error if the operation fails.case "playwright_hover": try { await page!.waitForSelector(args.selector); await page!.hover(args.selector); return { toolResult: { content: [{ type: "text", text: `Hovered ${args.selector}`, }], isError: false, }, }; } catch (error) { return { toolResult: { content: [{ type: "text", text: `Failed to hover ${args.selector}: ${(error as Error).message}`, }], isError: true, }, }; }
- src/tools.ts:71-77 (schema)Input schema defining the parameters for the 'playwright_hover' tool, which requires a CSS selector for the element to hover over.inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector for element to hover" }, }, required: ["selector"], },
- src/tools.ts:68-78 (registration)Registration of the 'playwright_hover' tool within the createToolDefinitions() function, including name, description, and input schema.{ 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/tools.ts:152-160 (helper)Helper constant BROWSER_TOOLS array that includes 'playwright_hover', used in toolsHandler.ts 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" ];