我有一个简单的线性布局,里面有两个文本视图。线性布局具有唯一ID,但textviews没有。如何验证其中一个文本来自这些文本视图?
我尝试了以下代码:
onView(allOf(NavigationDrawerComponent.topSectionWrapper,
hasSibling(withClassName(Matchers.equalTo(TextView.class.getSimpleName())))))
.check(matches(withText(Data.fullUserName)));
不幸的是,它不适合我。我收到以下错误:
android.support.test.espresso.NoMatchingViewException: No views in
hierarchy found matching
答案 0 :(得分:4)
./search: line 8: syntax error near unexpected token else
答案 1 :(得分:0)
有时您可能需要滚动RecyclerView
直到找到正确的子视图(如果该视图不可见,则可能尚未创建)。在这种情况下,仅使用scrollTo
是不够的,Android Studio不会自动推荐更好的选择。您必须这样做:
onView(withId(R.id.recycler_view))
.perform(RecyclerViewActions.scrollTo(hasDescendant(withText("Available"))));