I have a view hierarchy like below:
GridView{id=2131362110, res-name=item_list_grid,
|
+----->RelativeLayout{id=2131362124, res-name=item_image_thumb_layout
|
+------------->ImageView{id=2131362125, res-name=item_image
|
+----->RelativeLayout{id=2131362124, res-name=item_image_thumb_layout
|
+------------->ImageView{id=2131362125, res-name=item_image
|
+------>RelativeLayout{id=2131362124, res-name=item_image_thumb_layout
|
+------------->ImageView{id=2131362125, res-name=item_image
|
GridView{id=2131362110, res-name=item_list_grid, ...etc
I want to perfom click on one of the ImageView with id=item_image.
I can not use something like atPosition(x) together with onView so instead I used onData. I tried all of these:
onData(allOf(anything(),withId(R.id.item_image))).atPosition(0).perform(click());
onData(anything()).atPosition(0).perform(click());
onData(allOf(atPosition(0),withId(R.id.item_image))).perform(click());
But all resulted in
android.support.test.espresso.AmbiguousViewMatcherException: 'is assignable from class: class android.widget.AdapterView' matches multiple views in the hierarchy.
Any suggestions for this? Thanks!