我正在设置UI测试,并不断收到androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching:
错误消息
我的xml文件如下所示,具有多个类别
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:key="@string/key_preference_screen"
android:title="@string/sometitlename">
<PreferenceCategory
android:layout="@layout/category_layout"
android:key="@string/key_pref_">
<Preference
android:key="@string/key"
android:title="@string/pref_title"/>
</PreferenceCategory>
</PreferenceScreen>
我尝试过]的变体>
onData(allOf(`is`(instanceOf(Preference::class.java)),
withKey(R.string.key),
withTitle(R.string.pref_title)))
.onChildView(withText(pref_title))
.check(matches(isCompletelyDisplayed()))```
<< onView(withId(androidx.preference.R.id.recycler_view))
.perform(
RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(
1,
click()
))