Unable to use clickGesture

Since TouchActions have been deprecated in Appium 2.0, from my understanding we have to use different types of gestures.

I m trying to tap on an element at a specific point using clickGesture but I m getting this error

org.openqa.selenium.UnsupportedCommandException: Unknown mobile command “clickGesture”. Only shell,execEmuConsoleCommand,dragGesture,flingGesture,doubleClickGesture,longClickGesture,pinchCloseGesture,pinchOpenGesture,swipeGesture,scrollGesture,scrollBackTo,scroll,viewportScreenshot,viewportRect,deepLink,startLogsBroadcast,stopLogsBroadcast,acceptAlert,dismissAlert,batteryInfo,deviceInfo,getDeviceTime,changePermissions,getPermissions,performEditorAction,startScreenStreaming,stopScreenStreaming,getNotifications,listSms,type,sensorSet,deleteFile,clearApp,startActivity,startService,stopService,broadcast,getContexts,installMultipleApks,unlock commands are supported.

Code Snippet

  ((JavascriptExecutor) driver).executeScript("mobile: clickGesture", ImmutableMap.of(
          "x", 500, "y", 500
  ));

How to resolve this issue or are there any other alternatives ?

Using
Appium Server 1.21.0-1

try better -> http://appium.io/docs/en/commands/interactions/actions/

This gesture was only added recently. Consider updating the driver to the most recent version

It would be helpful if you can provide a code snippet equivalent to that mentioned in OP?

I m using java-client 8.0.0 or are you referring to appium-desktop ?

it is quite obvious…

Rectangle rectangle = ((WebElement) el).getRect();
Point point = new Point(rectangle.x + (rectangle.width / 2), rectangle.y + (rectangle.height / 2));
PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");
Sequence seq = new Sequence(finger, 1);
seq.addAction(finger.createPointerMove(Duration.ofMillis(0), PointerInput.Origin.viewport(), point.x, point.y));
seq.addAction(finger.createPointerDown(PointerInput.MouseButton.LEFT.asArg()));
seq.addAction(finger.createPointerMove(Duration.ofMillis(50), PointerInput.Origin.viewport(), point.x, point.y));
seq.addAction(finger.createPointerUp(PointerInput.MouseButton.LEFT.asArg()));
driver.perform(Arrays.asList(seq));
1 Like

Are the lines of code related to Sequence common to all ? or does it have any purpose

Sequence seq= new Sequence(finger, 1);
seq.addAction(finger.createPointerMove(Duration.ofMillis(0),
                    PointerInput.Origin.viewport(), source.x, source.y));
seq.addAction(finger.createPointerDown(PointerInput.MouseButton.LEFT.asArg()));
seq.addAction(finger.createPointerUp(PointerInput.MouseButton.LEFT.asArg()));
driver.perform(Arrays.asList(seq));

Do not understand your question…:upside_down_face:
But your code looks ok. Only need rename last “sec”.

@Aleksei I got the logic behind this but I have a small clarification.

In

Sequence seq= new Sequence(finger, 1);

what does 1 mean, what happens if I put 2?

Never used yet. I guess used when we have several fingers guesture.

Found more simple tap. Need to try…

https://stackoverflow.com/questions/71037969/how-to-use-actions-or-do-scroll-in-app-in-java

1 Like

@Aleksei Thanks mate… this link really helped