メインコンテンツにスキップ

スクロール

ブラウザのビューポート内でスクロールします。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