我有一个简单的线性布局,里面有两个 TextView 。线性布局有一个唯一的 id 但 textviews 没有。如何验证其中一个文本来自那些 TextView ?
我尝试了以下代码:
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
最佳答案
onView(withId(R.id.recycler_view)).check(matches(atPosition(0, hasDescendant(withText("Available")))));
关于java - Espresso Android 匹配父级中的 TextView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36852840/