我想在列表中查看Save€XX的显示.保存€XX是一个可见或不可见的TextView.我使用JUnit 4和Espresso 2.2.1.
我试着像这样检查:
onView(withText(startsWith("Save"))).check(matches(isDisplayed()));
但总是得到一个错误:
android.support.test.espresso.AmbiguousViewMatcherException: 'with text: a string starting with "Save"' matches multiple views in the hierarchy.
如果使用Espresso在ListView中存在TextView,有没有办法?
UPDATE
我也试过使用onData:
onData(hasToString(startsWith("Save"))) .inAdapterView(withId(R.id.suggestion_list_view)).atPosition(0) .check(matches(isDisplayed()));
但似乎onData适用于数据层,但不适用于视图层.因此,我收到错误:
java.lang.RuntimeException: No data found matching: with toString() a string starting with "Save" contained values: <[Data: ...]>