Skip to main content

Scroll Until Click

The Scroll Until Click action scrolls the screen in the specified direction until the target element becomes visible. Once found, the element is clicked automatically. This action is particularly useful for navigating long lists, settings pages, and menus where the required option is not initially visible.

When to Use

Use this action when you want to:

  • Open an option located further down a Settings page.
  • Select an item from a long list.
  • Navigate through application menus.
  • Scroll until a configuration option becomes visible.

Syntax

var task = suremdmjs.automate().scrollUntilClick(
"<Package Name>",
"<Direction>",
"<Element Text>"
);

suremdmjs.automate().performAction(
task,
"onSuccess",
"onFailure"
);

Parameters

ParameterRequiredDescription
Package NameYesPackage name of the target application. Leave empty ("") to search all applications.
DirectionYesDirection in which to scroll. Supported values are up, down, left, and right.
Element TextYesVisible text of the element to locate and click.

Parameter Details

Direction

Supported values:

up
down
left
right

Choose the direction based on where the target element is expected to appear.

Example

The following example scrolls through the Android Settings screen until the Developer Options menu becomes visible, then opens it.

!#suremdmjs

openDeveloperOptions();

function openDeveloperOptions() {

var task = suremdmjs.automate().scrollUntilClick(
"com.android.settings",
"down",
"Developer Options"
);

suremdmjs.automate().performAction(
task,
"developerOptionsOpened",
"optionNotFound"
);

}

function developerOptionsOpened() {
suremdmjs.log("Developer Options opened successfully.");
}

function optionNotFound() {
suremdmjs.log("Developer Options could not be located.");

}

How This Example Works

  1. Starts scrolling downward.
  2. Continuously searches for Developer Options.
  3. Stops scrolling when the option becomes visible.
  4. Clicks the option automatically.
  5. Executes the success callback.

Expected Result

The Developer Options page opens automatically.

note

If the target element cannot be found after the scroll operation reaches the end of the available content, the failure callback is executed.

💬 Help us improve this documentation

Was this information useful?

Your feedback helps us keep our documentation accurate, up to date, and useful.