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​

public Element scrollTo(String target)
public Element scrollTo(String target, String direction)

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

map() only sees what is currently visible. Tap, type and long-press already scroll to a target that is not, so reach for this to look without acting, or to scroll back up. This one scrolls down; nothing in the hierarchy says which way a container scrolls, so for any other way say so with scrollTo(String, String).

@param target a ref from map() such as "@e5", or a locator such as "text=Sign in" @return the element, with a fresh ref

Scrolls the given way until an element is on screen. Swiping the wrong way is not a no-op, so if a swipe navigates instead of scrolling, it stops after one.

@param target a ref from map() such as "@e5", or a locator such as "text=Sign in" @param direction "down", "up", "left" or "right" @return the element, with a fresh ref

Examples​

Scroll down until an element is on screen​

Element row = device.scrollTo("text=System"); // down is the default

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​

Element card = device.scrollTo("label=Card 8", "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