gpt4 book ai didi

java - Android espresso 在层次结构中找不到匹配的 View

转载 作者:行者123 更新时间:2023-12-01 18:28:17 26 4
gpt4 key购买 nike

我试图找到一个 View 并尝试了不同的组合,但根据所有 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}

你知道我做错了什么吗? enter image description here

最佳答案

您可以根据您的情况尝试一下。不幸的是,我无法确定 onData() 在这里如何工作,但在研究之后你应该尝试这样的事情:

onView(withId(R.id.title))
.check(matches(withText("Edit")))
.check(matches(isDisplayed()));

关于java - Android espresso 在层次结构中找不到匹配的 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60200742/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com