Updating Your Appium Automation Scripts: Replacing Deprecated tap(int x, int y)

Updating Your Appium Automation Scripts: Replacing Deprecated tap(int x, int y)

5 April 2024 Stephan Petzl Leave a comment Tech-Help

If you’re automating an Android game or any application where traditional element identification methods like ID or XPath are not feasible, you might have been utilizing the tap(int x, int y) method in Appium to simulate user taps on the screen. However, with updates to the Appium framework, this method has been deprecated. In this guide, we will walk you through the updated methods for achieving the same result using the new Appium API.

Understanding the Deprecated Methods

Previously, you might have written code similar to the following to perform a tap action at specific X and Y coordinates:

TouchAction touchAction = new TouchAction(driver);
touchAction.tap(1280, 1013).perform();

This method has now been deprecated and should be replaced with the new approach.

Using the New Tap Methods in Appium

The Appium framework has introduced new methods to perform tap actions. Below are the updated methods you should use:

  • PointOption.point(int x, int y): A static method that takes the coordinates as parameters and returns an instance of PointOption with those values.
  • PointOption().withCoordinates(int x, int y): This method returns a reference to the PointOption instance after setting the coordinate values.

Here’s how you can update your code using these methods:

Method 1: Using PointOption.point()

TouchAction touchAction = new TouchAction(driver);
touchAction.tap(PointOption.point(1280, 1013)).perform();

Method 2: Using PointOption().withCoordinates()

TouchAction touchAction = new TouchAction(driver);
touchAction.tap(new PointOption().withCoordinates(1280, 1013)).perform();


Updating your automation scripts to conform with the latest Appium API ensures your tests remain stable and future-proof. By using PointOption.point() or new PointOption().withCoordinates(), you can easily replace the deprecated tap(int x, int y) method and continue automating your Android games or other applications without interruption.

Remember to refer to the official Appium documentation for any further updates and best practices to maintain a robust automation suite.

Like this article? there’s more where that came from!