Unable to tap or press the elememtn on android

HI,

I was trying to tap or press the element on the page which is not detected by inspector or UiAutomator.
Earlier it was working fine to me, but now it not working, my solution which used earlier below,

    boolean MessageList = Driver.waitForElementPresentAppium(locator);

    if (MessageList == true) {

        Point point = Driver.getLocationByAppium(locator);

        Dimension size = Driver.getSizeByAppium(locator);

        int elementX = point.getX() + Math.round(size.getWidth()/2);

        int elementY = point.getY() + Math.round(size.getHeight()/2);

        int elementX1 = elementX +100;

        int elementY1 = elementY +150;

        TouchAction action = new TouchAction(driver);

        action.press(elementX1, elementY1).release().perform();

Here , i have taken nearest element X Y coordination which is present on page using Inspector and added some values (X Y) and tab the page. earlier it was working well (Same device).
Actually , i did some work around for tapping element on page using X Y cordinates, but it wouldn’t be permanent solution. Can you please any one help[ me to over come this issues.

How we can tap the page using X Y coordination on different device sizes(resoultions). Is there any permanent solution for the same using appium driver.

Is the location of the element proportionally the same on all devices? If you know it’s always, for example, 16% max_x and 20% max_y, you could use that.

If you can’t detect the element through Appium, I can’t easily think of another way to click it.

Hi Willosser,

Thanks for you reply…

Yes, element location is all most same place, but i have taken the nearest element and increased the x y coordinate for the next element which can’t detect by the inspector/UiAutomator Right now i am using Nexus 5 (Screen Size 5 inches).

If the devices orientation/size changes. how can i handle the above values.