Skip to main content

scroll_to

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.

scroll_to​

def scroll_to(target: str, direction: str='down') -> Element | None

Scroll until an element is on screen, and return it with a ref.

map() only sees what is currently visible, and tap(), type() and long_press() already scroll to a target that is not — so call this to look without acting, or to scroll back up. direction is "down", "up", "left" or "right" -- 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. Raises MobiumError if it is not found.

Examples​

Scroll down until an element is on screen​

el = device.scroll_to("text=System")
print(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​

device.scroll_to("label=Card 8", direction="right")

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