0

When I run following code, although I declare the view as visible, it always returns -1:

et = vc.findViewById('com.hamed.android:id/editText1')
time.sleep(2)
print et.getVisibility()

I check getVisibility() method and see that it returns -1 when an exception arise in getting visibility property. Where is my fault?

HaMi
  • 539
  • 6
  • 23
  • did you use this view in your setContent() ? – android_Muncher Jun 14 '14 at 10:49
  • No, I didn't. How can it raise exception?! – HaMi Jun 14 '14 at 10:57
  • if you don't set that view is it really visible ? Try setting it and then check what your code returns. – android_Muncher Jun 14 '14 at 10:58
  • I run my android application and work with it. The view is visible but I don't know why AVC raises exception! – HaMi Jun 14 '14 at 11:04
  • 1
    What if you use et = vc.findViewByIdOr Raise('com.hamed.android:id/editText1') and what if you perform refresh (dump) again after time.sleep(2) and then et = vc.findViewByIdOr Raise('com.hamed.android:id/editText1') again? (Maybe your et = vc.findViewById('com.hamed.android:id/editText1') returns None and maybe the view disappear etc after the sleep) – Prophet Jun 14 '14 at 18:33
  • Also try just `print et` to see what `et` contains – Diego Torres Milano Jun 15 '14 at 00:31
  • @dtmilano: It prints out: View[ class=android.widget.EditText index=2 selected=false NAF=true clickable=true package=com.mkyong.android text= long-clickable=true enabled=true bounds=((0, 128), (320, 176)) content-desc= focusable=true focused=true uniqueId=id/no_id/9 checkable=false resource-id=com.mkyong.android:id/editText1 password=false class=android.widget.EditText checked=false scrollable=false ] parent=android.widget.LinearLayout – HaMi Jun 15 '14 at 06:24
  • @Eliyahu: Thanks. but no result for your suggestions. – HaMi Jun 15 '14 at 06:28
  • There's no point in sleeping after finding the View – Diego Torres Milano Jun 15 '14 at 15:42

1 Answers1

0

UIAutomator does not return INVISIBLE Views in its dump. That's why they disappear, if they were VISIBLE before.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134