Skip to main content
Glama

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
NameRequiredDescriptionDefault
xYesX coordinate
yYesY coordinate

Implementation Reference

  • 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}`,
              },
            ],
          };
        }
      }
    );
  • 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});`);
    }
  • 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});`);
    }
  • Input schema using Zod: requires x and y as numbers with descriptions.
    {
      x: z.number().describe('X coordinate'),
      y: z.number().describe('Y coordinate'),
    },

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