react-native: [New Architecture] iOS - Unable to read Text attribute from TextInput with testId
Description
Recently after migrating to new architecture we are facing issue in locating TextInput in the automation test cases. Specifically we are not able to read the text value and the length of text of a TextInput element in Appium test cases.
What exactly happening here is that with new architecture is setting the specified testID to TextInput’s direct parent view (refer screenshot - New Architecture - Value available on child of element with specified testID.png) instead of setting it directly to the TextInput (as it works in old architecture, screenshot - Old Architecture.png).
React Native Version
0.72.3
Output of npx react-native info
System: OS: macOS 13.4.1 CPU: (12) arm64 Apple M2 Pro Memory: 936.34 MB / 32.00 GB Shell: version: “5.9” path: /bin/zsh Binaries: Node: version: 16.20.0 path: /usr/local/bin/node Yarn: version: 1.22.19 path: /opt/homebrew/bin/yarn npm: version: 8.19.4 path: /usr/local/bin/npm Watchman: version: 2023.06.26.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.12.1 path: /Users/ravindragupta/.rbenv/shims/pod SDKs: iOS SDK: Platforms: - DriverKit 22.4 - iOS 16.4 - macOS 13.3 - tvOS 16.4 - watchOS 9.4 Android SDK: Not Found IDEs: Android Studio: 2022.2 AI-222.4459.24.2221.10121639 Xcode: version: 14.3.1/14E300c path: /usr/bin/xcodebuild Languages: Java: version: 11.0.19 path: /usr/bin/javac Ruby: version: 3.0.4 path: /Users/ravindragupta/.rbenv/shims/ruby npmPackages: “@react-native-community/cli”: Not Found react: installed: 18.2.0 wanted: 18.2.0 react-native: installed: 0.72.1 wanted: 0.72.1 react-native-macos: Not Found npmGlobalPackages: “react-native”: Not Found Android: hermesEnabled: false newArchEnabled: true iOS: hermesEnabled: true newArchEnabled: true
Steps to reproduce
Add testId for TextInput and try to read text value from the element in automation test case (i.e. Appium)
Snack, code example, screenshot, or link to a repository
Reproducer App Link: https://github.com/ravindraguptacapgemini/reproducer-react-native-maps-events/tree/layout-animation-issue
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 15 (6 by maintainers)
@cortinico Just checking if you got some time to check this? We are getting these issues throughout the application after the fabric upgrade. In addition to these issues, after setting the accessibility label we were able to find out the elements but the element’s text is returning the accessibility id itself.
driver.find_element(:accessibility_id, ‘urlField’).text
Instead of “https://” we are getting “urlField”
I’ve reproduced this and confirmed it’s a New Architecture specific issue. Fix on the way.
@cortinico found out that now with new architecture, the testID is mapped to accessibilityIdentifier of a native component, previously it was being mapped to accessibilityLabel, that’s why the Appium was not able find the element (with accessibility-id).
We were used to passed testID for iOS and accessibilityLabel for android but now have to used both for iOS, as:
After all we have issue with multiple views in hierarchy specifying the same accessibilityLabel as in the screenshot: