openatx / uiautomator2

Android Uiautomator2 Python Wrapper
MIT License
6.61k stars 1.41k forks source link

List Element Issue (android.widget.ListView) #360

Open thlengane opened 5 years ago

thlengane commented 5 years ago

Hi, I am having issues dealing with list items. So when I do a .count, it returns zero but when I do a .exists, it returns true. There are three elements on the same parent, so if I do a .click(), it clicks the first item but when I click by index or instance, it does not find the element.

If I try d(className="android.widget.ListView").info, it shows it has childCount of 3 but .count still returns 0.

Below is the sample code I have

>>> d(resourceId="za.co.fnb.connect.itt:id/icon").count
0
>>> d(resourceId="za.co.fnb.connect.itt:id/icon").exists
True
>>> d(resourceId="za.co.fnb.connect.itt:id/left").count
0
>>> d(resourceId="za.co.fnb.connect.itt:id/left").exists
True
>>> d(resourceId="za.co.fnb.connect.itt:id/icon").count
0
>>> d(resourceId="za.co.fnb.connect.itt:id/icon").exists
True
>>>
>>> d(className="android.widget.ListView").info
{'bounds': {'bottom': 1317, 'left': 37, 'right': 1043, 'top': 924}, 'childCount': 3, 'className': 'android.widget.ListView', 'contentDescription': None, 'packageName': 'za.co.fnb.connect.itt', 'resourceName': None, 'text': None, 'visibleBounds': {'bottom': 1317, 'left': 37, 'right': 1043, 'top': 924}, 'checkable': False, 'checked': False, 'clickable': False, 'enabled': True, 'focusable': True, 'focused': True, 'longClickable': False, 'scrollable': False, 'selected': False}
>>>
>>> d(className="android.widget.ListView").count
0
>>>

Phone Model Samsung Galaxy A9 (SM-A920F/DS) Android 8.0

The version number of uiautomator2 ( pip show uiautomator2) Name: uiautomator2 Version: 0.2.3

Mobile phone screenshot issue

Full xml screen dump screen.zip

Please assist.

codeskyblue commented 5 years ago

uiautomator2 版本多少

thlengane commented 5 years ago

PS C:\Users\1> pip show uiautomator2 Name: uiautomator2 Version: 0.2.3 Summary: Python Wrapper for Android UiAutomator2 test tool Home-page: https://github.com/codeskyblue/uiautomator2 Author: codeskyblue Author-email: codeskyblue@gmail.com License: MIT Location: c:\python\lib\site-packages Requires: requests, six, humanize, fire, docopt, progress, retry, whichcraft, logzero, pillow, lxml Required-by: atx PS C:\Users\1>

codeskyblue commented 5 years ago

什么型号的手机,App要不也发给我下

thlengane commented 5 years ago

Samsung Galaxy A9 (SM-A920F/DS) Android 8.0

This is happening on all Android phones though. The app is available on the play store. Unfortunately to get to where the issue is, you have to login which we are not allowed to share.

codeskyblue commented 5 years ago

你看别的app是不是也有这个问题,给我说下也行

thlengane commented 5 years ago

Unfortunately I have only discovered it on this app, on that particular element. Reading through the issues though, I have found a similar bug logged. It happened on the ListView as well and it seems like it is not fixed. Check the link below.

https://github.com/openatx/uiautomator2/issues/137(url)

codeskyblue commented 5 years ago

@thlengane there is no issues 137

thlengane commented 5 years ago

@thlengane there is no issues 137

Updated the link, please check it again https://github.com/openatx/uiautomator2/issues/137(url)

mastrolube commented 3 years ago

Hello @codeskyblue !

I've found a strange behavior with the .exist() and I think it can be related to this. Sometimes I get exists: false but I checked and I have an object (count =1).

example

I'm using UIA2 2.15.0 on an emulator LDPlayer 4.0.45 which simulate a SM-G975N. The app is the instagram app 183.0.0.40.116. Thanks!

ps. forgor to say: I'm using the UI selector "textStartsWith="

thlengane commented 3 years ago

Hello @codeskyblue !

I've found a strange behavior with the .exist() and I think it can be related to this. Sometimes I get exists: false but I checked and I have an object (count =1).

example

I'm using UIA2 2.15.0 on an emulator LDPlayer 4.0.45 which simulate a SM-G975N. The app is the instagram app 183.0.0.40.116. Thanks!

ps. forgor to say: I'm using the UI selector "textStartsWith="

I can confirm that the issues are very much related, it's exactly the same behavior on my side.

githuuu commented 3 years ago

@codeskyblue 我这边也遇到类似的问题,应该是百分百的发生率。发生问题的控件主要集中在状态栏,虚拟导航栏和来电通知或者短信通知、闹钟之类的弹窗上,exists()是True,但是count为0:

oo.exists() True oo.exists(1) True oo[0].exists(1) False oo[0].exists() True 从代码上来看,exists()走的是"method": "exist",exists(1)走的是"method": "waitForExists"。 不太清楚这两个method有什么区别