In Espresso, how to avoid AmbiguousViewMatcherException when multiple views match

前端 未结 9 1483
情深已故
情深已故 2020-11-30 03:16

Having gridView which has some images. The gridView\'s cell comes out from same predefined layout, which has same id and desc.

R.id.item_image == 2131

9条回答
  •  广开言路
    2020-11-30 03:20

    You should use onData() to operate on GridView:

    onData(withId(R.id.item_image))
            .inAdapterView(withId(R.id.grid_adapter_id))
            .atPosition(0)
            .perform(click());
    

    This code will click on the image inside first item in GridView

提交回复
热议问题