scroll
Scroll within the browser viewport. Note that x
and y
coordinates are relative to the current
scroll positon, therefore browser.scroll(0, 0)
is a non operation.
Usage
browser.scroll(x, y)
Parameters
Name | Type | Details |
---|---|---|
x optional | number | horizontal scroll position (default: 0 ) |
y optional | number | vertical scroll position (default: 0 ) |
Example
scroll.js
it('should demonstrate the scroll command', async () => {
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
});