android / android/testing-samples

UiObject2 referring to wrong element

Open
#113 0 comments 0 reactions 0 assignees View on GitHub
not sample issue
Dominant language
Java
Stars
9.3k
Forks
3.6k
PR merge metrics
No merged PRs in 30d

Description

Referring to previously created `UiObject2` object which is not exist in the screen (in the same activity) pointing to a random element instead of throwing `StaleObjectException`.

Example code snippet:

```
UiObject2 elementInScrollView = mDevice.findObject(By.desc("Auto Complete"));
elementInScrollView.getText();
//returns "Auto Complete"

//scroll down to make sure that "Auto Complete" not present in the screen
mDevice.swipe(100, 400, 100, 50, 100);

elementInScrollView.getText();
//returns some random element text in the screen ex: List

mDevice.pressBack();
elementInScrollView.getText();
//throws `StaleObjectException`
```

Device API Level: 23
AUT: API Demos(Inbuilt app)

I suspect something wrong to `AccessibilityNodeInfo` [here](https://github.com/android/platform_frameworks_base/blob/master/core/java/android/view/accessibility/AccessibilityNodeInfo.java#L772) when `getAccessibilityNodeInfo` called from [UiObject2](https://android.googlesource.com/platform/frameworks/uiautomator/+/android-support-test/src/main/java/android/support/test/uiautomator/UiObject2.java#625)

PFA screenshot for the functional understanding.

![uiobject2 issue](https://cloud.githubusercontent.com/assets/4507565/19114424/8fc47cc2-8b2b-11e6-94d6-3c8925193213.png)

Contributor guide

Open the contributing guide

Research direction

Reproduce the behavior on API level 23 using the API Demos example and the existing UiObject2 and AccessibilityNodeInfo code linked in the report. Check why a previously found object returns another element after scrolling; done means the missing object throws StaleObjectException instead of returning unrelated text.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.