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
Name | Type | Description |
x | Number | Optional parameter. The x-coordinate to scroll to. Default: 0. |
y | Number | Optional 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
});
Related Commands
References
We'd like to give credit to the original WebdriverIO docs article, from which we drew some information while writing our version.