Assertion issue

im trying to add assertion that element shouldn’t be visible


and test fail however it should pass as
element is already not available and appium log shows

org.openqa.selenium.NoSuchElementException: Can’t locate an element by this strategy: By.chained({By.AndroidUIAutomator: new UiSelector().className(“android.view.View”).index(2).instance(5)})

im wondering since appium coundt find the element way the assertion is failing ?

have you ever faced similar issue ?

i do not use Displayed. i know that it often wrong and depending on developers for mobile apps (specially iOS)

so which assertion i can use to assert the element doesn’t exit or no displayed …etc

i check ONLY that element exist.
with element list:


as far as iOS became a bit slow from 13.3 i switched to element and some it attribute (check for el != NULL do not help here):

        try {
            if (el.getId().isEmpty())
                return false;
        } catch (Exception e) {
            return false;
1 Like

great thx i have tried now something similar , worked fine

@AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.view.View\").index(2).instance(5)")
List<MobileElement>  cardContent;