Android 安卓浓缩咖啡:如何匹配祖父母?没有给出确切的等级
在上面的代码段中,withParent的匹配器失败,因为给定的视图id不是直接父视图,而是父视图 它可以按如下方式处理,但很想知道诀窍,特别是当您不想指定下面代码中使用的混乱层次结构时Android 安卓浓缩咖啡:如何匹配祖父母?没有给出确切的等级,android,android-espresso,Android,Android Espresso,在上面的代码段中,withParent的匹配器失败,因为给定的视图id不是直接父视图,而是父视图 它可以按如下方式处理,但很想知道诀窍,特别是当您不想指定下面代码中使用的混乱层次结构时 onView(allOf( withText(activityUnderTest), withParent(withId(R.id.llh_root_record_activity_3_item)))) .check(matches(anything())) ; IsD
onView(allOf(
withText(activityUnderTest),
withParent(withId(R.id.llh_root_record_activity_3_item))))
.check(matches(anything())) ;
IsDescendatofa是您所需要的。
事实上,它不仅仅适用于祖父母。 请查收 @塔纳吉帕德瓦尔
onView(allOf(
withText(activityUnderTest),
withParent(withParent(withParent(withId(R.id.llh_root_record_activity_3_item))))))
.check(matches(anything())) ;
onView(allOf(withText(activityUnderTest), isDescendantOfA(withId(R.id.llh_root_record_activity_3_item))))
.check(matches(isDisplayed()));