React Native Environment Info:
System:
OS: Linux 4.15 Ubuntu 16.04.5 LTS (Xenial Xerus)
CPU: x64 Intel(R) Core(TM) i5-4310U CPU @ 2.00GHz
Memory: 1.19 GB / 15.57 GB
Shell: 4.3.48 - /bin/bash
Binaries:
Node: 10.6.0 - /usr/local/bin/node
Yarn: 1.9.4 - /usr/bin/yarn
npm: 6.1.0 - /usr/local/bin/npm
Watchman: 4.7.0 - /usr/local/bin/watchman
IDEs:
Android Studio: 3.1 AI-173.4819257
npmPackages:
react: ^16.5.0 => 16.5.1
react-native: 0.57.0 => 0.57.0
npmGlobalPackages:
react-native-cli: 2.0.1
Since updating to newest React Native we have an issue with our test automation effort due to the fact that all elements in Android hierarchy are now missing a 'class' field. This makes xpath unusable anymore.
Please note that classes were previously present for all components. F.e: 'android.view.View', 'android.widget.EditText' etc.)
Screenshot from UIAutomatorViewer:

Can you run react-native info and edit your issue to include these results under the Environment section?
If you believe this information is irrelevant to the reported issue, you may write [skip envinfo] under Environment to let us know.
We're also seeing this issue after upgrading from RN 0.55.4 to RN 0.57.1.
Here's my react-native info output:
React Native Environment Info:
System:
OS: macOS High Sierra 10.13.6
CPU: x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Memory: 227.38 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.11.4 - /usr/local/bin/node
Yarn: 1.9.4 - /usr/local/bin/yarn
npm: 5.6.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
IDEs:
Android Studio: 3.2 AI-181.5540.7.32.5014246
Xcode: 10.0/10A255 - /usr/bin/xcodebuild
npmPackages:
react: 16.5.1 => 16.5.1
react-native: 0.57.1 => 0.57.1
npmGlobalPackages:
generator-react-native-ignite: 1.13.0
react-native-cli: 2.0.1
react-native-ignite: 1.13.0
It seems that all views added to layouts by ReactNative are missing the class attribute, which, like @SinousX said, breaks all of our XPath queries. It also breaks all queries by content-desc. It seems that because the class information is missing, whatever is performing the queries doesn't know that ReactViewGroup instances in the tree are of type android.view.ViewGroup, so traversal stops early and views cannot be found.
Because of this, most of our automated tests are broken.
One interesting observation: if we manually add a ReactViewGroup to the Activity's contentView during the Activity.onCreate() lifecycle method, it shows up as a ReactViewGroup in the UiAutomator tool; but other Views added internally by ReactNative still have missing type information.
We are also experiencing this issue going from 0.55.4 to 0.57.1
The Appium team fixed appium-uiautomator2-server. See the attached ZIP file for a temporary fix for the issue until Appium desktop is updated. This seems to work well for me. Hopefully it works for you as well!
There is a README.md file in the ZIP that explains it. The upshot is that if you install the two APKs to the device/emulator before you run the Appium tests, Appium will not overwrite them with its own, and you can find the elements again!
Here is the Appium issue which indicated the fixes they made: https://github.com/appium/appium/issues/11513
Also, RN has a commit (linked off the Appium issue) which may possibly help address the problem: https://github.com/facebook/react-native/commit/fa6035bda6c606868977179534cb941f26fbdb9
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.
The issue is no longer reproducible after updating RN. Closing the issue.
Most helpful comment
We're also seeing this issue after upgrading from RN 0.55.4 to RN 0.57.1.
Here's my
react-native infooutput:It seems that all views added to layouts by ReactNative are missing the
classattribute, which, like @SinousX said, breaks all of ourXPathqueries. It also breaks all queries bycontent-desc. It seems that because the class information is missing, whatever is performing the queries doesn't know thatReactViewGroupinstances in the tree are of typeandroid.view.ViewGroup, so traversal stops early and views cannot be found.Because of this, most of our automated tests are broken.
One interesting observation: if we manually add a
ReactViewGroupto theActivity'scontentViewduring theActivity.onCreate()lifecycle method, it shows up as aReactViewGroupin the UiAutomator tool; but other Views added internally by ReactNative still have missing type information.