scroll
在瀏覽器視窗內滾動。 請注意,x
和 y
座標是相對於目前的滾動位置,因此 browser.scroll(0, 0)
是無效的操作。
用法
browser.scroll(x, y)
參數
名稱 | 類型 | 詳細資訊 |
---|---|---|
x 選用 | 數字 | 水平滾動位置 (預設值:0 ) |
y 選用 | 數字 | 垂直滾動位置 (預設值:0 ) |
範例
scroll.js
it('should demonstrate the scroll command', async () => {
await browser.url('https://webdriverio.dev.org.tw')
console.log(await browser.execute(() => window.scrollY)) // returns 0
await browser.scroll(0, 200)
console.log(await browser.execute(() => window.scrollY)) // returns 200
});