scrollUntilVisible

suspend fun scrollUntilVisible(containerTag: String, targetTag: String, direction: ScrollDirection = ScrollDirection.Down, maxScrolls: Int = 30, stabilizationDelayMs: Long = 300)

Repeatedly scrolls the container matching string containerTag in direction until targetTag becomes visible.

Primary method for revealing off-screen elements inside long lists or lazy layouts.

Example Usage

// Scroll down list until "Settings Item" becomes visible
scrollUntilVisible("settings_list", "Notification Settings")

Parameters

containerTag

The testTag or visible text of the scrollable container.

targetTag

The testTag or visible text of the element to reveal.

direction

The scroll direction (defaults to ScrollDirection.Down).

maxScrolls

Maximum number of scroll attempts before failing (default 30).

stabilizationDelayMs

Stabilization pause in milliseconds between scrolls (default 300ms).

Throws

If targetTag is not revealed within maxScrolls scroll attempts.


suspend fun scrollUntilVisible(containerSelector: Selector, targetSelector: Selector, direction: ScrollDirection = ScrollDirection.Down, maxScrolls: Int = 30, stabilizationDelayMs: Long = 300)

Repeatedly scrolls the container matching containerSelector in direction until targetSelector becomes visible.

Advanced variant using explicit selectors for container and target element lookup.

Example Usage

scrollUntilVisible(
containerSelector = tag("feed_list"),
targetSelector = text("Load More").first(),
direction = ScrollDirection.Down
)

Parameters

containerSelector

Explicit selector targeting the scrollable container.

targetSelector

Explicit selector targeting the element to reveal.

direction

The scroll direction (defaults to ScrollDirection.Down).

maxScrolls

Maximum number of scroll attempts before failing (default 30).

stabilizationDelayMs

Stabilization pause in milliseconds between scrolls (default 300ms).

Throws

If targetSelector is not revealed within maxScrolls scroll attempts.