DEV Community

Discussion on: An end to the abuse of Accessibility IDs

Collapse
 
vitalyiegorov profile image
Vitaly Iegorov • Edited

Does this work for "Text" elements on IOS? In our case Appium does not see Text testID="..."

Collapse
 
nextlevelbeard profile image
Ricardo Barbosa • Edited

That should indeed be the case yes, for whatever React Native version.
If it's not working make sure of two things:

  1. If any parent of the React Native Text component is a Touchable (TouchableOpacity for example) then you need to make sure to add accessible={false} to this parent component in order for you to be able to see this component's children like the Text. This happens because the default accessible value for Touchable components is true.
  2. You might have a very detailed screen with lots of elements and Appium at one point just gives up going down the tree and does not show every element. To avoid this, use Appium's Settings API by adding the capabilities appium:settings[snapshotMaxDepth] and appium:settings[customSnapshotTimeout] to your tests. Increase their default values to have more elements appear when finding strategies. Have a look here for the default values.