Skip to main content

Method Signature

await opensteer.scroll(options?: ScrollOptions): Promise<ActionResult>
Scrolls the page or a specific element. If no element is specified, scrolls the entire page.

Parameters

options
ScrollOptions
Configuration for the scroll action. Optional - defaults to scrolling the page down by 600 pixels.

Returns

ActionResult
Promise<ActionResult>

Examples

Scroll Page Down

// Scroll the page down by default amount (600px)
await opensteer.scroll()

// Or explicitly specify
await opensteer.scroll({
  direction: 'down'
})

Scroll Page Up

// Scroll the page up
await opensteer.scroll({
  direction: 'up'
})

Scroll Custom Amount

// Scroll down by 1000 pixels
await opensteer.scroll({
  direction: 'down',
  amount: 1000
})

Scroll Horizontal

// Scroll right
await opensteer.scroll({
  direction: 'right',
  amount: 500
})

// Scroll left
await opensteer.scroll({
  direction: 'left',
  amount: 500
})

Scroll Specific Element

// Scroll a scrollable container
await opensteer.scroll({
  description: 'Chat messages container',
  direction: 'down',
  amount: 300
})

Scroll with Selector

// Scroll element using CSS selector
await opensteer.scroll({
  selector: '.sidebar',
  description: 'Sidebar',
  direction: 'down'
})

Scroll to Load More Content

// Infinite scroll pattern
for (let i = 0; i < 5; i++) {
  await opensteer.scroll({
    direction: 'down',
    amount: 1000
  })
  
  // Wait for content to load
  await new Promise(resolve => setTimeout(resolve, 1000))
}

Scroll Element into View

// Scroll sidebar to reveal element
await opensteer.scroll({
  description: 'Navigation sidebar',
  direction: 'down',
  amount: 400
})

// Then interact with revealed element
await opensteer.click({
  description: 'Settings link'
})

Scroll with Element Counter

// Use element counter from snapshot
await opensteer.scroll({
  element: 35,
  description: 'Results container',
  direction: 'down',
  amount: 500
})

Important Notes

When no description, element, or selector is provided, the entire page is scrolled. This is useful for general page navigation.
The default scroll amount is 600 pixels, which typically moves the viewport by about one screen height on most displays.
  • click - Click on elements (may auto-scroll to element)
  • hover - Hover over elements
  • snapshot - Capture page content after scrolling