Skip to main content

Tap by Coordinates

The Tap by Coordinates action performs a single tap at the specified screen coordinates. Unlike the Click Element action, this method does not search for a UI element. It simply taps the specified screen location.

When to Use

Use this action when:

  • Interacting with custom UI controls.
  • Clicking map locations.
  • Selecting graphical objects.
  • Tapping image-based buttons.
  • Working with applications that do not expose Accessibility information.

Syntax

var task = suremdmjs.automate().clickCoordinates(
<X Coordinate>,
<Y Coordinate>
);

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

Parameters

ParameterRequiredDescription
X CoordinateYesHorizontal screen coordinate in pixels.
Y CoordinateYesVertical screen coordinate in pixels.

Parameter Details

X Coordinate

Specifies the horizontal position where the tap should occur.

Example:

540

Y Coordinate

Specifies the vertical position where the tap should occur.

Example:

1200

Example

The following example taps the centre of the device screen.

!#suremdmjs
tapScreen();

function tapScreen() {
var task = suremdmjs.automate().clickCoordinates(540,1200);
suremdmjs.automate().performAction(
task,
"tapCompleted",
"tapFailed"
);
}

function tapCompleted() {
suremdmjs.log("Screen tapped successfully.");
}

function tapFailed() {
suremdmjs.log("Unable to perform tap.");
}

How This Example Works

  1. Creates a Tap by Coordinates task.
  2. Specifies the X and Y coordinates.
  3. Performs a tap at the specified location.
  4. Executes the success callback after the tap completes.

Expected Result

A single tap is performed at the specified screen coordinates.

💬 Help us improve this documentation

Was this information useful?

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