1

How can I get the dump attribute in androidviewclient. for example, I want to get the attribute value of 'selected'.Please help!!

android attribute

  • This answer may help you. http://stackoverflow.com/questions/37693656/is-it-possible-with-androidviewclient-to-obtain-and-print-button-status – Madusanka May 17 '17 at 07:07
  • @MaDu_LK thanks for the reply, I can get the button or item Text by androidviewclient - gettext(), But I want to get the attribute value. – Huang Zheng May 17 '17 at 07:33

1 Answers1

0

If you run dump -a to dump all attributes you can see something like this (filtering selected):

$ dump -a | grep selected

        View[ class=android.widget.TextView index=2 selected=false checked=false clickable=false package=com.android.deskclock text=Tomorrow long-clickable=false enabled=true bounds=((36, 1455), (254, 1520)) content-desc= focusable=true focused=false uniqueId=id/no_id/29 checkable=false resource-id=com.android.deskclock:id/upcoming_instance_label password=false class=android.widget.TextView scrollable=false ]   parent=android.widget.LinearLayout

then, you can find any View using whatever attribute is appropriate for you case and invoke View.getSelected() as in this example:

com_android_deskclock___id_upcoming_instance_label = vc.findViewWithTextOrRaise(u'Tomorrow')
print "selected=", com_android_deskclock___id_upcoming_instance_label.getSelected()

this was generated using culebra, which is an excellent way of creating your tests or scripts automatically. I just added the print line.

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