hover_by_uid
Hover over webpage elements using unique identifiers from browser snapshots to inspect or interact with specific components during testing or automation.
Instructions
Hover over element by UID.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uid | Yes | Element UID from snapshot |
Implementation Reference
- src/tools/input.ts:171-191 (handler)MCP tool handler: validates input, gets Firefox instance via getFirefox(), calls firefox.hoverByUid(uid), handles errors with UID-specific messages, returns success/error MCP response.
export async function handleHoverByUid(args: unknown): Promise<McpToolResponse> { try { const { uid } = args as { uid: string }; if (!uid || typeof uid !== 'string') { throw new Error('uid parameter is required and must be a string'); } const { getFirefox } = await import('../index.js'); const firefox = await getFirefox(); try { await firefox.hoverByUid(uid); return successResponse(`✅ hover ${uid}`); } catch (error) { throw handleUidError(error as Error, uid); } } catch (error) { return errorResponse(error as Error); } } - src/tools/input.ts:47-60 (schema)Tool schema: defines name 'hover_by_uid', description, and inputSchema requiring 'uid' string from snapshot.
export const hoverByUidTool = { name: 'hover_by_uid', description: 'Hover over element by UID.', inputSchema: { type: 'object', properties: { uid: { type: 'string', description: 'Element UID from snapshot', }, }, required: ['uid'], }, }; - src/index.ts:132-132 (registration)Registers the handler function in the central toolHandlers Map for MCP server to route 'hover_by_uid' calls.
['hover_by_uid', tools.handleHoverByUid], - src/index.ts:176-176 (registration)Includes the tool schema in allTools array returned by listTools MCP request.
tools.hoverByUidTool, - src/firefox/dom.ts:152-161 (helper)Core implementation: resolves UID to WebElement via snapshot callback, performs mouse hover using Selenium async actions, waits for event propagation.
async hoverByUid(uid: string): Promise<void> { if (!this.resolveUid) { throw new Error('hoverByUid: resolveUid callback not set. Ensure snapshot is initialized.'); } const el = await this.resolveUid(uid); await this.driver.actions({ async: true }).move({ origin: el }).perform(); // Wait for events to propagate await this.waitForEventsAfterAction(); }