I want to check the display of Save β¬ XX in the list. Save β¬ XX is a TextView that can be VISIBLE or INVISIBLE . I am using JUnit 4 and Espresso 2.2.1.
I tried to check it like this:
onView(withText(startsWith("Save"))).check(matches(isDisplayed()));
but always get the error:
android.support.test.espresso.AmbiguousViewMatcherException: 'with text: a string starting with "Save"' matches multiple views in the hierarchy.
Is there a way if a TextView exists in a ListView with espresso?
UPDATE
I also tried using onData :
onData(hasToString(startsWith("Save"))) .inAdapterView(withId(R.id.suggestion_list_view)).atPosition(0) .check(matches(isDisplayed()));
but it seems that onData works with the data layer, but not with the presentation layer. So I get the error message:
java.lang.RuntimeException: No data found matching: with toString() a string starting with "Save" contained values: <[Data: ...]>

android junit junit4 android-espresso
Val
source share