Can a web element on iOS mobile device like a button can be NOT clickable while, is displayed=false, is enabled=true?

@Aleksei
I have a Flutter app, which I believe comes under native app on iOS device with Appium 2.0beta66, java_client 8.5, JDK 15.

I have a pageA with with a link A, by clicking which I go in to pageB with 3 links B1,B2,B3, each would take me to pageC Now after clicking link A, going to pageB, I successively click links B1, go to pageC, then come back to pageB by tapping on a back button. So after going to pageC for 3 times by clicking on links B1,B2,B3 one after another, and coming back to pageB each time. Finally after all this exercise was complete, when I am in pageB, I try to click a back button nothing is happening. Also by using the methods isDisplayed(), isEnabled() on the back button, I get is_displayed=false, is_enabled=true but could NOT able to click it. This same back button is working fine, if I go to page B and try to come back to pageA in other test cases. Basically 1 step out and back is working, but 2 steps out and back is NOT working.

I believe, by going through pageA–>pageB–>(3times)pageC, the back button on pageB has lost the reference in the DOM structure. But it is not throwing any StaleElementException??.

I waited on the back button for 20sec, 40sec, but in vain. But it is returning is_displayed=false, is_enabled=true.

How to resolve this issue ?
Thanks in advance for the help,

Enable disable visible or not are often not same as it actual. All depends on how app written.

  1. Make sure with every tap/click you do search element NOT use previous result of search.
  2. Make sure you tap on correct element
  3. Try tap by x, y. Get el center. Check manually that element center looks correct and you really tap into correct place. Tap by coordinates should work.
  4. Tap in webView inside native app can not work when you scroll, search el and tap it. In such case switch to webView, search el as usual for web e.g. by css locator and do click on element works muuch better.

Add example how you look for elements while browse app pages

@Aleksei
Your quick response is awesome and appreciated very much.
Yes, I am using tap by coordinates only. This is the sequence of bits of code, I am running.

  1. new TutorialPage().tapBackButton();
    @iOSXCUITFindBy(accessibility = "Back")*
   private WebElement backBtn;

public DashboardPage tapBackButton() {
try {
switch (params.getPlatformName()) {
case “Android”:
tapDeviceBackOptionAndroid();
break;
case “iOS”:
tapByElement(backBtn, “tap back button”);
break;
}
}catch(StaleElementReferenceException sere){
System.out.println(“>>>StaleElementReferenceException”+sere.getMessage());
}
return new DashboardPage();
}

public void tapByElement(WebElement e, String msg) {
waitForVisibility(e);
System.out.println(“tapByElement–>waitForVisibility displayed,enabled,”+e.isDisplayed()+“,”+e.isEnabled());
utils.log().info(msg);
Rectangle elRect = e.getRect();
Point point = new Point(
elRect.x + (int) (elRect.getWidth() / 2.0),
elRect.y + (int) (elRect.getHeight() / 2.0)
);
tapAtPoint(point);
}

  1.     protected void **tapAtPoint**(Point point) {
         PointerInput input = new PointerInput(TOUCH, "finger1");
         Sequence tap = new Sequence(input, 0);
         tap.addAction(input.createPointerMove(Duration.ZERO, viewport(), point.x, point.y));
         tap.addAction(input.createPointerDown(LEFT.asArg()));
         tap.addAction(new Pause(input, ofMillis(200)));
         tap.addAction(input.createPointerUp(LEFT.asArg()));
         driver.perform(ImmutableList.of(tap));
     }
    

try replace it with

@iOSXCUITFindBy(iOSNsPredicate = "(name == 'Back' OR value == 'Back') AND visible == 1")
private WebElement backBtn;

Possible there are MANY back buttons. Aach on each page you visited. As far as iOS shows ALL, while Android what visible on screen mostly.

You may check this by

 @iOSXCUITFindBy(accessibility = "Back")*
  private List<WebElement> backBtns;

// getting size of backBtns

@Aleksei
Thanks for your reply.
I tried your approach, even though, there are no multiple backBtns on any page.
I was thrown with this error message for the assertion to check for the visibility of the backBtn element. Please see the second line waitForVisibility(e) under code snippet (3) above.