[Android] TestID assigned to TextInput control not working
See original GitHub issueDescription
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
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:11
Top GitHub Comments
Actually there is a commit related to this issue but I didn’t test it. I think with RN version
0.65
you can useTestID
on Android. If your version is older than0.65
, can you upgrade your react-native and then try AndroidTestID
with both UIAutomator2 and Espresso?related topics: 381fb395ad9d2d48717a5d082aaedbecdd804554 https://github.com/facebook/react-native/pull/29610
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 useaccessibilityLabel
for Android, then you can use accessibilityId which is faster like accessing ID. Be careful becauseaccessibilityLabel
is also used for accessible apps for blind people