browser_scroll_by_pixels
Scroll web pages by specific pixel amounts horizontally and vertically to navigate content or position elements for interaction during browser automation.
Instructions
Scroll by a specific number of pixels
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | Yes | Number of pixels to scroll horizontally | |
| y | Yes | Number of pixels to scroll vertically |
Implementation Reference
- src/services/actionService.ts:87-89 (handler)Core handler implementation that executes JavaScript window.scrollBy(x, y) via Selenium WebDriver to perform the pixel-based scrolling.async scrollByPixels(x: number, y: number): Promise<void> { await this.driver.executeScript(`window.scrollBy(${x}, ${y});`); }
- src/tools/actionTools.ts:350-376 (registration)Registers the 'browser_scroll_by_pixels' tool with MCP server, including input schema (x, y pixels with Zod) and thin async handler that wraps ActionService.scrollByPixels with error handling and success message.server.tool( 'browser_scroll_by_pixels', 'Scroll by a specific number of pixels', { x: z.number().describe('Number of pixels to scroll horizontally'), y: z.number().describe('Number of pixels to scroll vertically'), }, async ({ x, y }) => { try { const driver = stateManager.getDriver(); const actionService = new ActionService(driver); await actionService.scrollByPixels(x, y); return { content: [{ type: 'text', text: `Scrolled by pixels (${x}, ${y})` }], }; } catch (e) { return { content: [ { type: 'text', text: `Error scrolling by pixels: ${(e as Error).message}`, }, ], }; } } );
- src/tools/index.ts:8-13 (registration)Top-level tool registration function that invokes registerActionTools, which includes the browser_scroll_by_pixels 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:353-356 (schema)Zod schema defining input parameters x (horizontal pixels) and y (vertical pixels) for the tool.{ x: z.number().describe('Number of pixels to scroll horizontally'), y: z.number().describe('Number of pixels to scroll vertically'), },