Different source trees from the same codebase are being created and thus Appium can’t reach elements in iOS that are seemingly way too deep.
How can I deal with this issue?
I tried updating the snapshotMaxDepth
setting to 60 and higher (even though the limit is 60), but sadly that did not fix the issue.
Edit
Appium version 1.21.0
Technology stack used to build the app is React Native
2
Answers
For those who will read this in the future and have stumbled across the same issues:
I have found that the issue itself was not because appium can not see deep enough into DOM/source tree (the issue with depth can still occur, but this was not the case for me yet). There are actually two different scenarios when stuff like this can happen and they both are to do with app code itself:
1 - Elements are nested inside a text component
Because of this appium will combine them into one text view and you won't be able to access the deeper elements. Solution is to move element out of the text component.
From this:
To this (obviously the styling will break, but appium will see the element):
2 - Container, row or any other parent div has pressable atributes
If any of the parent divs is considered as pressable - appium will think that that is a button and will return one combined view - by doing so not letting you to access all elements/button that are inside that container.
For example you have:
In this example case appium will return a one view component - that is all mushed together. What you need to do is change accessibility to false.
This would look like this:
By adding
accessible={false}
appium will now understand that this Container is not a accessible element and will now let you see whats deeper inside it.Hope this helps for the future people who stumble across the same issues :)
React Native behaves differently for iOS as it does for Android. React Native has elements that are accessible. By default, all touchable elements are accessible. This indicates that the view is an accessibility element. When an element is an accessibility element, it groups its children into a single selectable component, see also https://reactnative.dev/docs/accessibility.
It can also depend on the navigation that you/your developers are using, see appium/appium#14825
How to overcome:
customSnapshotTimeout
and orsnapshotMaxDepth
, see https://github.com/appium/appium-xcuitest-driver. Sometimes it takes to long to build up the tree and by adjusting these values you might give Appium more time to translate the tree. You mentioned you already tried it, so it might be related to the accessible elements, see next point.