0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Playwright で部分スクロールが出来ない場合の解決策はクリックで

Posted at

問題

ページ本体ではなく、ページ内に部分スクロールできる要素がある場合
Playwrightでスクロール処理が出来ない

次のようなものを試してみたが無理だった

await page.mouse.move(0, 0)
await page.mouse.down()
await mouse.wheel(deltaX, deltaY)
await page.keyboard.press('PageDown')

解決

スクロールさせたい位置にある要素をクリックすることで、ページ位置がそこまで移動してくれるので、これで暫定解決した

HTML

<div data-testid="wanna-scroll-to">
なにかの要素
</div>

Playwright

await page.getByTestId('wanna-scroll-to').click()

ただし当たり前だがクリック処理も起こってしまい、副作用が出る場合もあるので注意

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

プロフィール・経歴

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?