onView(allOf(withText(activityUnderTest), withParent(withId(R.id.llh_root_record_activity_3_item)))).check(matches(anything())) ;
Run Code Online (Sandbox Code Playgroud)
在上面的代码片段withParent匹配器失败,因为给出的视图ID不是直接父级而是祖父级.
它可以如下处理,但很想知道这个技巧,特别是当你不想指定下面代码中使用的凌乱层次结构时.
onView(allOf(withText(activityUnderTest), withParent(withParent(withParent(withId(R.id.llh_root_record_activity_3_item)))))).check(matches(anything())) ;
Run Code Online (Sandbox Code Playgroud)
小智 26
isDescendantOfA是您所需要的.
实际上,它不适用于大父母.请检查浓缩咖啡备忘单
onView(allOf(withText(activityUnderTest), isDescendantOfA(withId(R.id.llh_root_record_activity_3_item))))
.check(matches(isDisplayed()));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3804 次 |
| 最近记录: |