【发布时间】:2019-08-14 23:49:20
【问题描述】:
我正在设置 UI 测试并不断收到 androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching:error 消息
我的 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()))```
【问题讨论】:
标签: android kotlin android-espresso ui-testing