NOT tapping on x and y coordinate in Appium


Following code is not working on Appium (iOS). I tried different ios device, but it’s not clicking on the x & y coordinate.

Might be you will think it’s button, so it can click directly, but it’s not clicking and that’s why I wrote following code.

MobileElement myElement = driver.findElementByXPath("//XCUIElementTypeButton[@name=‘Have an account? Sign in’]");
System.out.println("========>" + myElement.getText()); // Printing label correctly.
int centerx = myElement.getLocation().getX() + (myElement.getSize().getWidth() / 2);
int centery = myElement.getLocation().getY() + (myElement.getSize().getHeight() / 2);
System.out.println(“Center X :”+ centerx);
System.out.println(“Center Y :”+ centery);
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, Object> tapObject = new HashMap<String, Object>();
js.executeScript(“mobile: tap”, tapObject);

Appium server is not throwing any kind of error.