滚动
在浏览器视口内滚动。请注意,x
和y
坐标是相对于当前滚动位置的,因此browser.scroll(0, 0)
是一个无效操作。
用法
browser.scroll(x, y)
参数
名称 | 类型 | 详细信息 |
---|---|---|
x=0 可选 | number | 水平滚动位置(默认:0 ) |
y=0 可选 | number | 垂直滚动位置(默认:0 ) |
示例
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
});