Skip to main content
Glama

browser_scroll_by_pixels

Control browser scrolling precisely by specifying exact pixel amounts horizontally and vertically for automated web testing and interaction.

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

  • Registers the 'browser_scroll_by_pixels' MCP tool, including input schema (x, y pixels), description, and handler function that uses ActionService to perform the scroll.
    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}`, }, ], }; } } );
  • The MCP tool handler function that executes the scroll by instantiating ActionService and calling scrollByPixels.
    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}`, }, ], }; } }
  • Zod input schema defining 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'), },
  • Supporting method in ActionService that executes the JavaScript window.scrollBy(x, y) via Selenium WebDriver to perform the actual scrolling.
    async scrollByPixels(x: number, y: number): Promise<void> { await this.driver.executeScript(`window.scrollBy(${x}, ${y});`); }

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