跳至主要內容

scroll

在瀏覽器視窗內滾動。 請注意,xy 座標是相對於目前的滾動位置,因此 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
});

歡迎!我能幫您什麼嗎?

WebdriverIO AI Copilot