browser_scroll_to_coordinates
Scroll the browser viewport to specific X and Y coordinates for precise positioning during web 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/tools/actionTools.ts:323-348 (registration)Registration of the 'browser_scroll_to_coordinates' tool using McpServer.tool(), including schema and inline handler function that calls ActionService.scrollToCoordinates.'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/services/actionService.ts:83-85 (handler)The core handler logic delegated from the tool handler: executes JavaScript to scroll the window to the specified (x, y) coordinates using Selenium WebDriver.async scrollToCoordinates(x: number, y: number): Promise<void> { await this.driver.executeScript(`window.scrollTo(${x}, ${y});`); }
- src/services/actionService.ts:83-85 (helper)Helper method in ActionService that implements the scrolling by injecting JavaScript `window.scrollTo(x, y)`.async scrollToCoordinates(x: number, y: number): Promise<void> { await this.driver.executeScript(`window.scrollTo(${x}, ${y});`); }
- src/tools/actionTools.ts:325-328 (schema)Input schema using Zod: requires x and y as numbers with descriptions.{ x: z.number().describe('X coordinate'), y: z.number().describe('Y coordinate'), },