Skip to main content
Scroll the page up or down with the mouse wheel:
If the page doesn’t move, click somewhere on it first to give it focus.

Signature

Parameters

'up' | 'down'
default:"down"
Which way to scroll. 'left' and 'right' aren’t supported: TestDriver logs an error and doesn’t scroll.
object

Errors

Throws an error if direction isn’t 'up', 'down', 'left' or 'right'. If the screen doesn’t change after the scroll, TestDriver logs a warning instead of throwing. This usually means the page didn’t have focus.

Scroll until text appears

testdriver.scrollUntilText() scrolls in steps until it finds some text on screen:
object
required
It throws an error if the text doesn’t appear within maxDistance. testdriver.scrollUntilImage({ description }) works the same way for an image you describe.

Examples

Focus the page, then scroll

Load more results in an infinite list

Use the keyboard instead

Some apps don’t respond to the mouse wheel. Press Page Down with pressKeys():

Complete example

tests/scroll.test.mjs