browser_hover
Hover over web elements to trigger dropdowns, tooltips, or interactive menus using Selenium WebDriver for browser automation and testing.
Instructions
Hover over an element
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| by | Yes | Locator strategy to find element | |
| value | Yes | Value for the locator strategy | |
| timeout | No | Maximum time to wait for element in milliseconds |
Implementation Reference
- src/tools/actionTools.ts:8-31 (registration)Registers the 'browser_hover' MCP tool, including its description, input schema reference, and inline handler function that delegates to ActionService.server.tool( 'browser_hover', 'Hover over an element', { ...locatorSchema }, async ({ by, value, timeout = 15000 }) => { try { const driver = stateManager.getDriver(); const actionService = new ActionService(driver); await actionService.hoverOverElement({ by, value, timeout }); return { content: [{ type: 'text', text: 'Hovered over element' }], }; } catch (e) { return { content: [ { type: 'text', text: `Error hovering over element: ${(e as Error).message}`, }, ], }; } } );
- src/services/actionService.ts:9-14 (handler)Core handler logic for hovering over an element using Selenium WebDriver's action builder to move the mouse to the located element.async hoverOverElement(params: LocatorParams): Promise<void> { const locator = LocatorFactory.createLocator(params.by, params.value); const element = await this.driver.wait(until.elementLocated(locator), params.timeout || 15000); const actions = this.driver.actions({ bridge: true }); await actions.move({ origin: element }).perform(); }
- src/types/index.ts:29-35 (schema)Zod schema definition for element locator parameters (by, value, timeout), used as the input schema for the browser_hover tool.export const locatorSchema = { by: z .enum(['id', 'css', 'xpath', 'name', 'tag', 'class', 'link', 'partialLink']) .describe('Locator strategy to find element'), value: z.string().describe('Value for the locator strategy'), timeout: z.number().optional().describe('Maximum time to wait for element in milliseconds'), };
- src/tools/index.ts:11-11 (registration)Calls registerActionTools in the aggregate tool registration function, which includes the browser_hover tool registration.registerActionTools(server, stateManager);