跳到主要内容

滚动

在浏览器视口内滚动。请注意,xy坐标是相对于当前滚动位置的,因此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
});

Welcome! How can I help?

WebdriverIO AI Copilot