Overview
Scrolls an element in a specified direction by a given amount. Uses AX-first strategy with a 10-step activation chain to maximize compatibility across different scrollable element types.Syntax
Parameters
Element reference from snapshot (must be scrollable)
Scroll direction:
up, down, left, rightNumber of scroll units (typically lines or pages)
Response
Response Fields
The action performed (
scroll)The element reference that was scrolled
AX-First Strategy
The scroll command uses a 10-step activation chain:- Try
kAXScrollToVisibleActionif applicable - Try
kAXIncrementAction/kAXDecrementAction - Try setting scroll bar position via AX
- Try arrow key presses (up/down/left/right)
- Try page up/down keys
- Try scroll wheel events at element center
- Try dragging scroll bar
- Try mouse wheel events
- Try trackpad gestures
- Fall back to coordinate-based scroll
Direction Values
| Direction | Behavior |
|---|---|
up | Scroll content upward (show earlier content) |
down | Scroll content downward (show later content) |
left | Scroll content leftward |
right | Scroll content rightward |
Usage Examples
Scroll Down in Window
Scroll Up
Scroll Horizontally
Scroll with Defaults
Scroll Until Element Appears
Scroll Amount
The--amount parameter typically represents:
| Element Type | Amount Unit |
|---|---|
| Text area | Lines |
| List | Items |
| Page view | Pages |
| Canvas | Pixels (varies) |
Supported Element Types
| Role | Scroll Behavior |
|---|---|
scrollarea | Primary scroll target |
list | Scroll list items |
textarea | Scroll text content |
table | Scroll table rows |
webarea | Scroll web page content |
outline | Scroll outline items |
Error Cases
| Error Code | Cause | Recovery |
|---|---|---|
ELEMENT_NOT_FOUND | Ref doesn’t exist in current refmap | Run snapshot to refresh |
STALE_REF | Element no longer matches saved ref | Run snapshot and use new ref |
ACTION_FAILED | Element is not scrollable | Element may not have scrollable content |
INVALID_ARGS | Invalid direction or amount | Use valid direction (up/down/left/right) |
Scroll vs Scroll-To
| Command | Use Case | Target |
|---|---|---|
scroll | Scroll by amount in direction | Relative movement |
scroll-to | Scroll element into view | Specific element |
scroll when:
- You want to scroll by a specific amount
- Direction matters
- Exploring content incrementally
scroll-to when:
- You have a ref to the target element
- You want to ensure element is visible
- Absolute positioning needed
Scroll Patterns
Scroll to Top
Scroll to Bottom
Page Down
Smooth Scroll
Performance Notes
- Scroll operations may trigger content loading (infinite scroll)
- Some apps redraw content during scroll (adds latency)
- Large scroll amounts may take longer to complete
- Consider
waitafter scroll to allow content to stabilize
Verifying Scroll
Notes
- Scroll amount interpretation varies by element type
- Some elements may not respond to all directions
- Scrolling may reveal new elements; snapshot after scroll
- For precise element visibility, use
scroll-toinstead - Scroll bars are separate elements that can also be scrolled
- Mouse wheel fallback works when AX methods fail
- Large amounts may cause multiple scroll events
- Always add
waitafter scroll for content to stabilize