In Espresso, how to avoid AmbiguousViewMatcherException when multiple views match

前端 未结 9 1443
情深已故
情深已故 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:31

    Not completely related to grid view situation but you can use hamcrest allOf matchers to combine multiple conditions:

    import static org.hamcrest.CoreMatchers.allOf;
    
    onView(allOf(withId(R.id.login_password), 
                 withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
            .check(matches(isCompletelyDisplayed()))
            .check(matches(withHint(R.string.password_placeholder)));
    

提交回复
热议问题