Skip to main content
Glama

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
NameRequiredDescriptionDefault
selectorYesCSS selector for element to hover

Implementation Reference

  • 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, }; }
  • 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"], }, },
  • 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, }));
  • 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);

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/lars-hagen/mcp-playwright-cdp'

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