xiaocong / uiautomator

Python wrapper of Android uiautomator test tool.
MIT License
2.03k stars 638 forks source link

sometimes can't find uiobject but object do exists #162

Open smiley-yoyo opened 8 years ago

smiley-yoyo commented 8 years ago

By testing some app, I notice that sometimes I can see ui on screen, but uiautomator can't find the uiobject. When I dump window hierarchy to xml using code, seeing thing are difference from what I dump from adb uiautomatorviewer tool. The xml dumped from code, lesser element than dumped from uiautomatorviewer. I find out that the dump difference is cause by the compressed argument. And, if I set compressed to false, the uiobject can be found by uiautomator again. I guess what I need is setCompressedLayoutHeirarchy method, but it is not expose by uiautomator. After review the server code I think I can use dump(compressed=False) to do this. So, can it be a good idea to explicitly set compressed layout hierarchy on or off? Thank you very much.

siva-kranthi commented 8 years ago

We also faced similar issue. If you set compressed=False, it will only effect the XML dump, but not the selector. Am I right?

smiley-yoyo commented 8 years ago

No. In my situation, set compressed=False also effect the selector.

siva-kranthi commented 8 years ago

You are right. It is working fine for selectors also. thanks

siva-kranthi commented 8 years ago

FYI https://github.com/xiaocong/uiautomator/issues/156

shfscut commented 7 years ago

@wicked-wei @hongbinbao We also faced similar issue. My situation is like that

  1. Go to the Settings - Accessibility interface
  2. Disconnect the USB cable
  3. Reconnect the USB cable
  4. device (text = 'Speak passwords').exists ---->returns false
  5. Press the home key to enter the home screen
  6. Re-enter the Settings - Accessibility interface 7.device (text = 'Speak passwords').exists ---->returns true

Note: uiautomator: 0.2.7 latest release

shfscut commented 7 years ago

supplement: Only part of the phone appears the phenomenon, you can ignore the phenomenon, thank you!