Appium iOS finding invisible elements with all locators

@Aleksei
I’m currently using the appium 1.15v desktop tool for iOS object spy testing. During object spy with the provided ID/Xpath/Predicate, the element was identified even though it was not displayed on the screen, and also the element’s visible attribute was false only. The element is not identified only if I send the visible attribute as false to the locators during object spy. This is happening only in iOS, not in Android.

Appium version - 1.15
iPhone version - 13v an d12v
React native application.

it is normal for iOS.

It shouldn’t perform like this , when we finding the invisible elements identification right. why is it normal in iOS? One more question is, is this an issue or a behaviour for iOS? & it shouldn’t found the elements which are not being visible on the screen during object spy?

why is it normal in iOS? - is it how XCUITest works. you may try ask Apple to fix this.

1 Like

Okay thank you for ur support .

@Mirudhu_Yuvaraj You can use visible attribute to check if the element is visible on the screen or not in iOS
In Android you can see the invisible elements by setting allowInvisibleElements to true

yeah with the visible attribute only currently forming the xpath to locate the objects. My question is, why it’s showing all the invisible elements in iOS where in android, it’s not showing up same element with the same provided ID when the element is invisible on the screen?

When i do object spy, I’m passing only the accessibility id to search the element. So, this Accessibility id is same for both the apps in android and iOS. During object spy, invisible element wasn’t identified in Android whereas in iOS , it was found.

unfortunately its the XCUITest behaviour, if you want the same behaviour across Android and iOS set allowInvisibleElements to True in Android.

@Ravi_Kishore Okay thank you.

I’ve been seeing this as well - our iOS devs couldn’t find anything that was setting the elements to visible==false, so we are just work arounding it with enabled.
This will not always work, but you could try it.

$driver.find_element(predicate: ‘type=‘XCUIElementTypeImage’ AND name =‘back_arrow’ AND enabled = 1’)