Android эспрессо Нет подходящих представлений в иерархии - PullRequest
0 голосов
/ 13 февраля 2020

Я пытался найти представление и пробовал разные комбинации, но мой лог c выглядит правильно по всем примерам 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

1 Ответ

0 голосов
/ 13 февраля 2020

Вы можете попробовать это в вашем случае. К сожалению, я не могу быть уверен в том, как onData () может работать здесь, но после исследования вы должны попробовать что-то вроде этого:

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

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...