dtmilano / CulebraTester2-public

CulebraTester: Snaky Android Testing
Apache License 2.0
139 stars 29 forks source link

How to select by index when there is more than one object by same id #1

Closed vjyanand closed 4 years ago

vjyanand commented 4 years ago

uiDevice/findObject?resourceId=com.google.android:id/row_simple_text_textview. How to select nth element of row_simple_text_textview? Thanks

dtmilano commented 4 years ago

Not sure how you are invoking it (python?) but you can use

uiDevice/findObjects?bySelector=res@com.google.android:id/row_simple_text_textview

(notice the plural, Objects).

Then you can select the nth element of the array.

vjyanand commented 4 years ago

Sorry for my overlook

dtmilano commented 4 years ago

@vjyanand no worries, it has been recently added.

It returns something like

[{'class_name': 'android.widget.TextView', 'oid': 1}, {'class_name': 'android.widget.TextView', 'oid': 2}, {'class_name': 'android.widget.TextView', 'oid': 3}, {'class_name': 'android.widget.TextView', 'oid': 4}, {'class_name': 'android.widget.TextView', 'oid': 5}, {'class_name': 'android.widget.TextView', 'oid': 6}]