Skip to main content

scroll

Overview

Use the scroll command to scroll the browser viewport. Note that the x and y coordinates refer to the current scrolling position of the viewport.

Usage

await browser.scroll(x, y);

Command Parameters

NameTypeDescription
xNumberOptional parameter. The x-coordinate to scroll to. Default: 0.
yNumberOptional parameter. The y-coordinate to scroll to. Default: 0.

Usage Examples

it("should demonstrate the scroll command", async ({ browser }) => {
await browser.url("https://webdriver.io");

console.log(await browser.execute(() => window.scrollY)); // returns 0
await browser.scroll(0, 200);
console.log(await browser.execute(() => window.scrollY)); // returns 200
});

References

We'd like to give credit to the original WebdriverIO docs article, from which we drew some information while writing our version.