Skip to main content
Glama

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
NameRequiredDescriptionDefault
xYesNumber of pixels to scroll horizontally
yYesNumber of pixels to scroll vertically

Implementation Reference

  • 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});`); }
  • 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}`, }, ], }; } } );
  • 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); }
  • 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'), },

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