Reading React Native iOS elements

Hello! I’m writing here by suggestion on the XCUITest driver issue section.

I’m facing an issue with a React Native application I’m testing. The application is made in react native and, in general is OK and accessible to Appium.

However, there are some elements in the code, for example react native’s <Text> that I’m not able to make it work in the tests.

A bit of context:

  • An element inside a list that contains a <View>. Inside that <View> there’s a view and a button and inside the 2nd view, 2 <Text> elements.
  • The <Text> elements both have the testID property set from react native’s code

With appium inspector I see the item element as 2 separate elements. One is the button and One is the texts one unique XCUIElementTypeOther (is only seen as one). When I read the XCUIElementTypeOther element, it groups both contained texts. So, if the first <Text> contains the text “Card Title 1” and the seconds <Text> contains “Card Sub Title 1”, appium sees it as “Card Title 1 Card Sub Title 1 ” (including that weird character at the end)

Things to notice:

  • No id was displayed

If I add to one of <Text> elements the “accessibilityLabel”, appium sees everything the same, except the testid is added to the element text as such “Card Title 1 test-id-edit-priorities-card-ios-sub-title ”

So, my question is. Have anyone faced this issue and know how to solve it?

React native “react-native”: “0.76.7”,
Appium 2.13.1
Driver [email protected]

Capabilities I’m using

{
  "appium:automationName": "XCUITest",
  "platformName": "iOS",
  "appium:app": "my_app_here",
  "appium:settings[snapshotMaxDepth]": "65",
  "appium:noReset": true,
  "appium:autoAcceptAlerts": false,
  "appium:settings[boundElementsByIndex]": "true",
  "appium:platformVersion": "17.5",
  "appium:deviceName": "iPhone 15",
  "appium:showXcodeLog": true
}

Note on this one, we’ve tried even setting it to higher numbers and didn’t worked
“appium:settings[snapshotMaxDepth]”: “65”

Note 2: This same scenario and same code is working OK with Android. So I’m assuming is either on how Appium reads these elements or how the RN elements are built.

What you describe I see with some elements of our app which is pure native written with Swift.
Common issues like button or cell with inside some elements. Sometimes we even do not see these elements until we make them accessible while parent element not (something like → link). iOS magic.

Ohh got it! Now it worked for some of the elements. I need to check with the ones that are not working what the hell is happening.

What I don’t like much about this is how the accesibility is being handled, but I’ll talk with the devs to reach a middle ground.

Thanks!