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

scrollIntoView

要素をビューポートにスクロールします(MDNリファレンス)。

使用法
$(selector).scrollIntoView(scrollIntoViewOptions)
パラメータ
名前詳細
scrollIntoViewOptionsobject, booleanElement.scrollIntoView() のオプション (デフォルト: { block: 'start', inline: 'nearest' })
scrollIntoView.js
it('should demonstrate the scrollIntoView command', async () => {
const elem = await $('#myElement');
// scroll to specific element
await elem.scrollIntoView();
// center element within the viewport
await elem.scrollIntoView({ block: 'center', inline: 'center' });
});

ようこそ!何かお手伝いできることはありますか?

WebdriverIO AI Copilot