Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] TestID assigned to TextInput control not working #32969

Open
anchitkoul opened this issue Jan 26, 2022 · 19 comments
Open

[Android] TestID assigned to TextInput control not working #32969

anchitkoul opened this issue Jan 26, 2022 · 19 comments
Labels

Comments

@anchitkoul
Copy link

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

  1. Add Test ID to TextInput component
  2. Open app on Android Emulator
  3. 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

@react-native-bot react-native-bot added Component: TextInput Related to the TextInput component. Platform: Android Android applications. labels Jan 26, 2022
@rguerra712
Copy link

Anyone by chance have a workaround for this? We are suffering from the same problem.

@OksanaHanailiuk
Copy link

Hey guys, I am faced with the same problem? Any progress on this?
Thanks

@jennifer-dickinson
Copy link

Also experiencing this same issue.

@anchitkoul
Copy link
Author

is someone looking into this issue?

@keremoge
Copy link

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 use accessibilityLabel for Android, then you can use accessibilityId which is faster like accessing ID. Be careful because accessibilityLabel is also used for accessible apps for blind people

@anchitkoul
Copy link
Author

Thats exactly the reason we don't want to use accessibilityLabel , our organization takes accessibility very seriously

@keremoge
Copy link

keremoge commented May 13, 2022

Thats exactly the reason we don't want to use accessibilityLabel , our organization takes accessibility very seriously

Actually there is a commit related to this issue but I didn't test it. I think with RN version 0.65 you can use TestID on Android.
If your version is older than 0.65, can you upgrade your react-native and then try Android TestID with both UIAutomator2 and Espresso?

related topics:
381fb39
#29610

@anchitkoul
Copy link
Author

has anyone seen it working in 0.65+ version?

@brett-james-rocketlab
Copy link

No, although if you give your testid a globally unique name it can:
testID='com.your.app:id/password'

@siebertm
Copy link

on v0.66, testID works mostly, but not for TextInput! It seems that it's simply not setting resource-id for andoid (works fine on ios)

@diego-epicura
Copy link

on v0.66, testID works mostly, but not for TextInput! It seems that it's simply not setting resource-id for andoid (works fine on ios)

Same here, any workarounds?

@chetstone
Copy link
Contributor

PR #31865 was supposed to fix this but I'm not having any luck on RN 0.70.5

@brett-james-rocketlab
Copy link

Did you try a globally unique test id? because on Android you need it to be unique, #32969 (comment) . Does it still not work with that?

@chetstone
Copy link
Contributor

@brett-james-rocketlab Thanks for your reply. I did see your comment and I thought
something like io.malamode.signInUser would be good enough to make it globally unique but it didn't work.

After running the test, I got the message

Unused text input: no resource name matched the regex "io.malamode.signInUser"

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/user but 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
Copy link

brett-james-rocketlab commented 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
Copy link

Suffering from the same problem.

@tobywisener
Copy link

Suffering for the same problem, but also for View's, TextInputs etc

@anatooly
Copy link

anatooly commented 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
Copy link

shubhamdeol commented May 27, 2024

anyone tested this in react-native:0.74 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests