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.
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.
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();
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
TouchAction action= new TouchAction(driver);
action.press(271, 642).release().perform();