question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android] TestID assigned to TextInput control not working

See original GitHub issue

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

  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

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:5
  • Comments:11

github_iconTop GitHub Comments

1reaction
keremogecommented, 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: 381fb395ad9d2d48717a5d082aaedbecdd804554 https://github.com/facebook/react-native/pull/29610

1reaction
keremogecommented, 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 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

Read more comments on GitHub >

github_iconTop Results From Across the Web

TextInput label/id not getting picked up in detox - Stack Overflow
I have a TextInput element with both accessibilityLabel and testID set to email. However, detox cannot find UI element with by.id or ...
Read more >
Hey, I have an issue with TestID for Android. TestID assigned to ...
Discussion on: An end to the abuse of Accessibility IDs ... Hey, I have an issue with TestID for Android. TestID assigned to...
Read more >
react-native-community/datetimepicker - npm
React Native date & time picker component for iOS, Android and Windows ... Other configurations are very likely to work as well but...
Read more >
Testing your Compose layout - Jetpack - Android Developers
Diagram showing a typical UI layout, and the way that layout would map to a ... For example, given a button like this...
Read more >
Queries | React Native Testing Library - Open Source
In the spirit of the guiding principles, it is recommended to use this only after the other queries don't work for your use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found