react-native: [Android] TestID assigned to TextInput control not working
Description
Adding TestID on Android platform to TextInput does not show up in Appium Inspector or Appium tests.
“react”: “^16.12.0”, “react-native”: “^0.64.3”,
Appium Doctor v.1.15.3
Version
16.12.0
Output of npx react-native info
System: OS: macOS 10.15.7 CPU: (8) x64 Intel® Core™ i7-4770HQ CPU @ 2.20GHz Memory: 36.09 MB / 16.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 16.2.0 - /usr/local/bin/node Yarn: 1.22.17 - /usr/local/bin/yarn npm: 7.13.0 - /usr/local/bin/npm Watchman: 2021.11.08.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 Android SDK: API Levels: 30 Build Tools: 28.0.3, 29.0.3, 32.0.0 System Images: android-30 | ARM 64 v8a, android-30 | Intel x86 Atom_64, android-30 | Google APIs Intel x86 Atom, android-30 | Google APIs Intel x86 Atom_64 Android NDK: Not Found IDEs: Android Studio: 2020.3 AI-203.7717.56.2031.7935034 Xcode: 12.4/12D4e - /usr/bin/xcodebuild Languages: Java: 1.8.0_292 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: Not Found react-native: ^0.64.3 => 0.64.3 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Steps to reproduce
- Add Test ID to TextInput component
- Open app on Android Emulator
- Open Appium inspector to inspect this component / Write Appium test to inspect this component
Expected: testID value should be present in ID attribute of the component. Result : testID value is not present in ID attribute
import { TextInput } from 'react-native';
<TextInput
testID={item.testID}
editable={!disabled}
maxLength={maxLength}
accessibilityLabel={ariaLabel}
onChangeText={onChangeText}
selectionColor={colorMapping.blue}
style={[composedStyle.textbox, isiOS && !innerLabel ? {} : innerLabelBorderStyle]}
underlineColorAndroid='transparent'
onFocus={onFocus}
onBlur={onBlur}
value={value}
accessibilityLabel={ariaLabel}
/>
Snack, code example, screenshot, or link to a repository
No response
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 13
- Comments: 24 (2 by maintainers)
I think using UIAutomator2 or Espresso for Appium on Android won’t be able to set ID even if you set
TestID, but if You useaccessibilityLabelfor Android, then you can use accessibilityId which is faster like accessing ID. Be careful becauseaccessibilityLabelis also used for accessible apps for blind peopleI’m trying to tackle the different issues related to the
testIDon Android (see: #48254 & #48271). I am unable to reproduce this one unfortunately. I’m doing this in the playground with the latest from thereact-nativecore.With the following code, I see it works for both cases when the testID is repeated and also when it is unique.
Screenshots:
See the `resource-id`'s being set in Appium Inspector:
See the `resource-id`'s being set in Maestro Studio:
Seems like something got fixed since this was first reported. I think we could close it this one, unless somebody can confirm it is still happening and can provide a minimal repro using the latest RN version. Then I’d be happy to troubleshoot it
Actually there is a commit related to this issue but I didn’t test it. I think with RN version
0.65you can useTestIDon Android. If your version is older than0.65, can you upgrade your react-native and then try AndroidTestIDwith both UIAutomator2 and Espresso?related topics: 381fb395ad9d2d48717a5d082aaedbecdd804554 https://github.com/facebook/react-native/pull/29610