android / android/android-test

UIAutomator does nothing on WebView in API 26/27

Open
#1,015 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.2k
Forks
342
Avg merge
11h 29m
Merged PRs (30d)
2

Description

### Description

We have an issue whereby UiAutomator does not find any view elements within a WebView whilst running on an Nexus 5X API 26 emulator image, both freshly created and on Firebase Test Lab's set of virtual devices.

This could do with more narrowing down but so far I believe I see it on any API 26 or 27 devices. It's certainly not universal - it works on other emulators and real devices.

UiAutomator does work to some extent on this emulator, as it did find native view elements on the first fragment shown.

It may or may not be relevant, but we see this in Logcat:

`07-17 06:26:04.062: W/dex2oat(9241): Rejecting class androidx.test.uiautomator.UiAutomatorInstrumentationTestRunner that attempts to sub-type erroneous class android.test.InstrumentationTestRunner in base.apk`

`UiAutomatorInstrumentationTestRunner` is AndroidX but it extends the deprecated `InstrumentationTestRunner`, which is not, and would be present in `com.google.android:android-test`.

### Tested So Far

*Fail*

- Nexus 5X API 26 local emulator
- Nexus 5X API 26 Firebase Test Lab virtual device
- Pixel 4 API 26 local emulator
- Pixel 4 API 27 local emulator

*Pass*

- Custom spec API 25 local emulator
- Pixel 4 API 28 local emulator
- Nexus 5X API 29 local emulator
- Pixel 2 API 29 Firebase Test Lab virtual device
- Samsung S21 5G Ultra API 30 real device

### Steps to Reproduce

1. Clone https://github.com/robpridham-bbc/UIAutomatorExample
2. Run `ExampleInstrumentedTest` on a:
a. Nexus 5X API 26 emulator
b. (for example) Pixel 3a API 29 emulator
3. Observe whether the test passes on both

### Expected Results

The app under test should load the page into the WebView, and the test should locate the heading text. It should pass.

Additionally, UiAutomator should not depend on legacy Android test libraries from before AndroidX, so the given Logcat snippet should not appear.

### Actual Results

The test fails on the API 26 emulator because UiAutomator cannot locate the view.

It passes on the API 29 emulator.

### AndroidX Test and Android OS Versions

Android 8.0 (API 26)
UiAutomator 2.2.0

### Link to a public git repo demonstrating the problem:

See above.

Contributor guide

Open the contributing guide

Research direction

Clone the linked UIAutomatorExample repository and run ExampleInstrumentedTest on the listed API 26 and API 29 emulator configurations. Compare the WebView element lookup and the API 26 Logcat warning about UiAutomatorInstrumentationTestRunner and legacy Android test libraries. Done means the heading is found on API 26/27 and the reported legacy-library warning is resolved or explained.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.