Skip to main content

ScrollTo

This tool on every surface: CLI · MCP · Python · JavaScript · Go · Java · .NET

Scroll until an element is on screen — all of it, when it fits — then return it with a ref. These call app_scroll_to.

ScrollTo​

func (d *Device) ScrollTo(ctx context.Context, target, direction string) (*Element, error)

ScrollTo scrolls until an element is on screen and returns it with a ref.

Map only sees what is currently visible. Tap, Type and LongPress already scroll to a target that is not, so reach for this to look without acting, or to scroll back up. direction is Down, Up, Left or Right, and "" is Down: nothing on screen says which way a container scrolls, so a horizontal pager needs Left or Right. Swiping the wrong way is not a no-op, so if a swipe navigates instead of scrolling, it stops after one.

Examples​

Scroll down until an element is on screen​

el, err := dev.ScrollTo(ctx, "text=System", "")
if err != nil {
return err
}
fmt.Println(el.Ref)

The same call from the command line, mobium scroll-to text=System, printed on an Android 15 emulator:

text=System is on screen after 2 scrolls down — @e9 System Languages, gestures, time, backup (button)
BeforeAfter
Before: mobium scroll-to text=System on an Android 15 emulatorAfter: mobium scroll-to text=System on an Android 15 emulator

mobium scroll-to text=System on an Android 15 emulator

Scroll a horizontal pager​

el, err := dev.ScrollTo(ctx, "label=Card 8", "right")
if err != nil {
return err
}
fmt.Println(el.Ref)

The same call from the command line, mobium scroll-to "label=Card 8" --direction right, printed on an Android 15 emulator:

label=Card 8 is on screen after 7 scrolls right — @e5 Card 8 (button)
BeforeAfter
Before: mobium scroll-to "label=Card 8" --direction right on MobiumApp's Pager Demo, Android 15 emulator: from Card 1 to where Card 8 is in the pager's view and can be tapped — it stops as soon as it is, so here only Card 8's left edge shows, at the rightAfter: mobium scroll-to "label=Card 8" --direction right on MobiumApp's Pager Demo, Android 15 emulator: from Card 1 to where Card 8 is in the pager's view and can be tapped — it stops as soon as it is, so here only Card 8's left edge shows, at the right

mobium scroll-to "label=Card 8" --direction right on MobiumApp's Pager Demo, Android 15 emulator: from Card 1 to where Card 8 is in the pager's view and can be tapped — it stops as soon as it is, so here only Card 8's left edge shows, at the right