Well ...I had more issues to solve to make it work ... it was "only" this:
- 1. increase
snapshotMaxDepth
so all elements are returned, default is 50
- add to capability row:
appium:settings[snapshotMaxDepth]: 80
- 2. switch off animations (we had idle animation)
- I was getting this error and timeouts:
Waiting up to 2s until com.myap is in idle state (including animations)
3. do NOT add accessibilityLabel
directly to <Text>
component
if you do this:
<View>
<Text accessibilityLabel="testID">TEXT_I_WANT</Text>
</View>
snapshot will look somehow like this:
<XCUIElementTypeOther ...>
<XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="testID" name="testID" label="testID"/>
</XCUIElementTypeOther>
instead, add it to the parent component:
<View accessibilityLabel="testID">
<Text>TEXT_I_WANT</Text>
</View>
snapshot:
<XCUIElementTypeOther type="XCUIElementTypeOther" name="testID" label="testID">
<XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="TEXT_I_WANT" name="TEXT_I_WANT" label="TEXT_I_WANT"/>
</XCUIElementTypeOther>
After that, I had to get text from component by additional call:
const element = await driver.$('~testID')
const elems = await element.$$('XCUIElementTypeStaticText')
const myTextElement = await elems[0].getText()
console.log(myTextElement)
What helped me to find such an easy way was to try all hints from this Appium issue thread: App element tree (on IOS) not looking good #10654.
NOTE: still open to better solution