Skip to main content

Swipe

The Swipe action performs a swipe gesture in the specified direction. It is commonly used to navigate between screens, scroll through content, dismiss notifications, or reveal hidden UI elements. The swipe is performed relative to the device screen and does not require any coordinates.

When to Use

Use this action when you want to:

  • Scroll through a list or page.
  • Navigate between application screens.
  • Open the notification panel.
  • Dismiss notifications.
  • Move through image galleries.
  • Reveal additional content.

Syntax

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

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

Parameters

ParameterRequiredDescription
Package NameYesPackage name of the target application. Leave empty ("") to perform the gesture on the currently active screen.
DirectionYesDirection in which the swipe should be performed.

Parameter Details

Package Name

Specifies the application where the swipe should be executed.

Example:

com.android.settings

To perform the gesture on the currently active screen, pass an empty string.

""

Direction

Supported values are:

  • up
  • down
  • left
  • right

Choose the direction based on the required navigation.

Example

The following example scrolls down through the Android Settings page.

!#suremdmjs

scrollSettings();

function scrollSettings() {

var task = suremdmjs.automate().swipe(
"com.android.settings",
"up"
);

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

}

function onScrollCompleted() {
suremdmjs.log("Settings page scrolled successfully.");
}

function onFailure() {
suremdmjs.log("Unable to perform swipe.");
}

How This Example Works

  1. Creates a Swipe task.
  2. Performs an upward swipe on the Android Settings screen.
  3. Waits until the gesture completes.
  4. Executes the success callback.

Expected Result

The screen scrolls upward, revealing additional settings.

note

Swipe performs a single gesture. If multiple swipes are required, execute additional Swipe actions from the success callback.

💬 Help us improve this documentation

Was this information useful?

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