Repository navigation
[Android] TestID assigned to TextInput control not working #32969
Description
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(R) Core(TM) 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
Activity
rguerra712 commentedon Mar 18, 2022
Anyone by chance have a workaround for this? We are suffering from the same problem.
OksanaHanailiuk commentedon Mar 22, 2022
Hey guys, I am faced with the same problem? Any progress on this?
Thanks
jennifer-dickinson commentedon Apr 4, 2022
Also experiencing this same issue.
anchitkoul commentedon Apr 20, 2022
is someone looking into this issue?
keremoge commentedon May 11, 2022
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 peopleanchitkoul commentedon May 12, 2022
Thats exactly the reason we don't want to use accessibilityLabel , our organization takes accessibility very seriously
keremoge commentedon May 13, 2022
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 than
0.65, can you upgrade your react-native and then try AndroidTestIDwith both UIAutomator2 and Espresso?related topics:
381fb39
#29610
anchitkoul commentedon May 31, 2022
has anyone seen it working in 0.65+ version?
brett-james-rocketlab commentedon Oct 21, 2022
No, although if you give your testid a globally unique name it can:
testID='com.your.app:id/password'
siebertm commentedon Nov 14, 2022
on v0.66,
testIDworks mostly, but not forTextInput! It seems that it's simply not settingresource-idfor andoid (works fine on ios)diego-epicura commentedon Nov 21, 2022
Same here, any workarounds?
2 remaining items
chetstone commentedon Apr 4, 2023
@brett-james-rocketlab Thanks for your reply. I did see your comment and I thought
something like
io.malamode.signInUserwould be good enough to make it globally unique but it didn't work.After running the test, I got the message
I'm trying to test using firebase-test-lab rather than one of the other tools mentioned in this thread. I just tried something closer to the exact format you mention in your example:
io.malamode:id/userbut when I try to enter that in the test account credentials field in the Test Lab Presets setup, I get the message: Invalid character ':'So I'm not sure how to make it globally unique, if that's what the problem is.
I wonder if it has anything to do with it treating the resource ID as a regex?
brett-james-rocketlab commentedon Apr 4, 2023
@chetstone Ok you sound like you've done all the right things there then. What you can also do is launch appium + appium inspector (it can take a bit to setup - the. goal is to be able to see a representation of what your app is rendering):
, and then confirm what you are setting is appearing there - this is because you'll see the field you've added, including it's xpath. You should expect to see your testid etc to appear there.
shankarRxo commentedon May 31, 2023
Suffering from the same problem.
tobywisener commentedon Sep 11, 2023
Suffering for the same problem, but also for View's, TextInputs etc
anatooly commentedon Jan 18, 2024
Unused text input: no resource name matched the regex "email"
not work too
<TextInput testID="email" />"react-native": "0.72.7", and "react-native": "0.73.4"
shubhamdeol commentedon May 27, 2024
anyone tested this in
react-native:0.74?react-native-bot commentedon Nov 24, 2024
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
brett-james-rocketlab commentedon Nov 24, 2024
This would be good to see resolved. I'll try spin up a v0.76.x build this week - fabric renderer might make this more tricky.
Since I first filed this, I moved from Appium, to Maestro Studio for testing because its much more flexible at handling this.
mateoguzmana commentedon Dec 14, 2024
I'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
react-native-bot commentedon Jun 13, 2025
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
react-native-bot commentedon Jun 20, 2025
This issue was closed because it has been stalled for 7 days with no activity.