Skip to main content
Glama

browser_hover

Hover over web elements to trigger dropdown menus, tooltips, or interactive content using locator strategies like ID, CSS, or XPath for automated browser testing.

Instructions

Hover over an element

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
byYesLocator strategy to find element
timeoutNoMaximum time to wait for element in milliseconds
valueYesValue for the locator strategy

Implementation Reference

  • Registers the 'browser_hover' MCP tool, providing description, input schema (locatorSchema), and handler function that uses ActionService to perform the hover.
    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}`, }, ], }; } } );
  • Core implementation of 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(); }
  • Zod schema definition for element locator parameters (by, value, timeout), spread into the tool's input schema.
    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'), };

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/pshivapr/selenium-mcp'

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