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][UIAutomatorViewer] Missing Class attribute in UIAutomatorViewer #21238

Closed
SinousX opened this issue Sep 21, 2018 · 6 comments
Closed
Labels
Platform: Android Android applications. Platform: Linux Building on Linux. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@SinousX
Copy link

SinousX commented Sep 21, 2018

Environment

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

Description

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:

noclassesuiautomator

Reproducible Demo

  1. Open any React Native app with abovementioned environment
  2. Open UIAutomatorViewer
  3. Notice elements DO NOT have classes assigned to them
@react-native-bot react-native-bot added Platform: Android Android applications. Platform: Linux Building on Linux. labels Sep 21, 2018
@react-native-bot
Copy link
Collaborator

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.

@clangen-nw
Copy link

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.

@idulkin
Copy link

idulkin commented Oct 3, 2018

We are also experiencing this issue going from 0.55.4 to 0.57.1

@eburke56
Copy link

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: appium/appium#11513

Also, RN has a commit (linked off the Appium issue) which may possibly help address the problem: fa6035b

appium-fix-android.zip

@stale
Copy link

stale bot commented Jan 16, 2019

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.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 16, 2019
@SinousX
Copy link
Author

SinousX commented Jan 24, 2019

The issue is no longer reproducible after updating RN. Closing the issue.

@SinousX SinousX closed this as completed Jan 24, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Jan 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Platform: Android Android applications. Platform: Linux Building on Linux. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

5 participants