Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose the testID to black-box testing frameworks on Android (#29610)
Summary: There has been a long-standing issue where black-box testing frameworks like Appium and Xamarin UITest have not been able to access the `testID` view prop for Android (see #7135). A natural place for this to be exposed is via a view's `resource-id`. The `resource-id` is what I have used when working on UIAutomator-based tests for native Android apps and is a non-localized, development-only identifier. As mentioned in the linked ticket, you can dynamically set the resource-id using the view's AccessibilityNodeInfo. This change simply checks to see if a testID is provided for a view and then exposes it through the view's accessibility node delegate. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [Android] [Fixed] - Fixes #7135, #9942, and #16137. Display the `testID` as the `resource-id` for black-box testing frameworks Pull Request resolved: #29610 Test Plan: I used the `uiautomatorviewer` tool to verify that the resource-id is populated with the `testID` of a few different views of the RNTester app. <img width="912" alt="Screen Shot 2020-08-10 at 3 38 27 PM" src="https://user-images.githubusercontent.com/875498/89838534-55044100-db20-11ea-9be2-ba507a81f6fb.png"> <img width="1096" alt="Screen Shot 2020-08-10 at 3 40 41 PM" src="https://user-images.githubusercontent.com/875498/89838542-5897c800-db20-11ea-9895-462c6fea1130.png"> Reviewed By: JoshuaGross Differential Revision: D25799550 Pulled By: fkgozali fbshipit-source-id: e64ff1b90fb66b427fce7af533aa94792cfbcad3
- Loading branch information
381fb39
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jdeff
I am on react-native 0.62. So I took your changes locally to node_modules (path:ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java ) and tried to test my application with UI Automator view and unable to get the vlaues for resource-id. Its always empty.
Am I missing something here ?
381fb39
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sasmit I don't believe that changing the local java files in
node_modules
will work. See #29610 (comment) for more information.381fb39
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jdeff I tried all the steps mentioned in https://github.com/facebook/react-native/wiki/Building-from-source . but still there is some error while building in android studio. Below is the error
Execution failed for task ':ReactAndroid:buildReactNdkLib'.
This is the result of react-native info
info Fetching system and libraries information...
System:
OS: Windows 10 10.0.19042
CPU: (8) x64 Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
Memory: 3.70 GB / 15.82 GB
Binaries:
Node: 12.10.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.10.3 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels: 28, 29, 30
Build Tools: 28.0.3, 29.0.0, 29.0.2, 30.0.2
System Images: android-28 | Android TV Intel x86 Atom, android-30 | Google APIs Intel x86 Atom
Android NDK: 20.1.5948944
Windows SDK: Not Found
IDEs:
Android Studio: Version 4.1.0.0 AI-201.8743.12.41.6858069
Visual Studio: Not Found
Languages:
Java: 1.8.0_211
Python: 3.9.0
npmPackages:
@react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: file:../../fork/react-native => 0.62.2
react-native-windows: Not Found
npmGlobalPackages:
react-native: Not Found