browser_scroll_to_coordinates
Navigate web pages by scrolling to exact pixel coordinates (X and Y positions) for precise browser automation and testing.
Instructions
Scroll to specific coordinates
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | Yes | X coordinate | |
| y | Yes | Y coordinate |
Implementation Reference
- src/services/actionService.ts:83-85 (handler)Core implementation of scrolling to specific coordinates using Selenium WebDriver's executeScript to run window.scrollTo(x, y). This is the exact logic executed for the tool.async scrollToCoordinates(x: number, y: number): Promise<void> { await this.driver.executeScript(`window.scrollTo(${x}, ${y});`); }
- src/tools/actionTools.ts:322-348 (registration)Registers the 'browser_scroll_to_coordinates' MCP tool, defines input schema (x, y coordinates), and provides wrapper handler that creates ActionService and calls the core scroll method.server.tool( 'browser_scroll_to_coordinates', 'Scroll to specific coordinates', { x: z.number().describe('X coordinate'), y: z.number().describe('Y coordinate'), }, async ({ x, y }) => { try { const driver = stateManager.getDriver(); const actionService = new ActionService(driver); await actionService.scrollToCoordinates(x, y); return { content: [{ type: 'text', text: `Scrolled to coordinates (${x}, ${y})` }], }; } catch (e) { return { content: [ { type: 'text', text: `Error scrolling to coordinates: ${(e as Error).message}`, }, ], }; } } );
- src/tools/index.ts:8-13 (registration)High-level registration entry point that calls registerActionTools, thereby including the browser_scroll_to_coordinates tool.export function registerAllTools(server: McpServer, stateManager: StateManager): void { registerBrowserTools(server, stateManager); registerElementTools(server, stateManager); registerActionTools(server, stateManager); registerCookieTools(server, stateManager); }
- src/tools/actionTools.ts:325-328 (schema)Zod schema for tool inputs: x and y as numbers.{ x: z.number().describe('X coordinate'), y: z.number().describe('Y coordinate'), },