![](/img/trans.png)
[英]Android::android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching
[英]Android espresso No views in hierarchy found matching
我试图找到一个视图并尝试了不同的组合,但根据所有 stackoverflow 示例,我的逻辑看起来是正确的。
我的代码:
onData(anything()).inAdapterView(
instanceOf(ListView::class.java))
.atPosition(0)
.onChildView(withId(android.R.id.title))
.check(matches(withText("Edit")))
.check(matches(isDisplayed()))
它抛出错误:
E/TestRunner: androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching: (with id: android:id/title and is descendant of a: displaying data matching: ANYTHING within adapter view matching: an instance of android.widget.ListView)
If the target view is not part of the view hierarchy, you may need to use Espresso.onData to load it from one of the following AdapterViews:androidx.appcompat.widget.MenuPopupWindow$MenuDropDownListView{3df3337 VFED.VC.. ........ 0,0-539,264}
您可以针对您的情况尝试使用此方法。 不幸的是,我不能确定 onData() 在这里如何工作,但在研究之后你应该尝试这样的事情:
onView(withId(R.id.title))
.check(matches(withText("Edit")))
.check(matches(isDisplayed()));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.