This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
1 / 5
Feb 2016

I am trying to tap on particular location/place by finding coordinates of that location. I don't want find element, I want to find coordinates and then click on that particular position. Please help me to do this.

  • created

    Feb '16
  • last reply

    Jan '19
  • 4

    replies

  • 4.4k

    views

  • 5

    users

  • 1

    like

  • 1

    link

You can get the screen dimensions using

Dimension dimens = driver.manage().window().getSize();
double xCoordinate = dimens.getWidth() * 0.5;
double yCoordinate = dimens.getHeight() * 0.5;
//you may have to cast these values to int

Using these values in a tap for example:

driver.tap(1, xCoordinate, yCoordinate, 800);

will cause Appium to tap in the middle of the screen using one finger for 800 milliseconds.

1 year later

With current version of Java client 5.0.0-BETA6, tap is deprecated. Below solution needs to be used

new TouchAction(getDriver()).tap(xCoordinate, yCoordinate).perform();

1 year later

To who is looking for C# Appium:

AppiumDriver _myDriver;

_myDriver = new AndroidDriver(new Uri(“http://127.0.0.1:4723/wd/hub”), cap);

TouchAction touchHere = new TouchAction(_myDriver );
touchHere.Tap(993, 1953).Perform();

//993 is x coordinates, and 1953 is y coordinates

8 months later

TouchAction action= new TouchAction(driver);
action.press(271, 642).release().perform();