Skip to main content

Overview

Scroll the page or the active element in any direction with the mouse wheel or the keyboard.
Focus RequirementsA scroll needs focus on the page or on a frame. If an input field or another interactive element has focus, scroll commands can fail. Before you scroll, put the focus on the page:
  • Click a non-interactive area (for example, the page background)
  • Push the Escape key to remove the focus from interactive elements
  • Click outside of input fields or text areas
If the scroll still does not work, use the Page Down or Page Up keys directly:

Syntax

Parameters

string
default:"down"
Direction to scroll: 'up', 'down'
object

Returns

Promise<void>

Examples

Basic Scrolling

Horizontal Scrolling

Scroll Methods

Best Practices

Make sure that the page has focus before you scroll
Control the scroll distance with the options object
The keyboard scroll uses Page Down and Page UpA keyboard scroll usually moves one “page” each time. This can be more than the click amount that you set. It is more compatible than a mouse scroll, but it is less precise.

Use Cases

Complete Example

  • find() - Find elements after a scroll
  • pressKeys() - Use the Page Down and Page Up keys
  • wait() - Wait after a scroll