Ho questo codice nel mio test EspressoAndroid Espresso controllo selezionata testo filatore
onView(withId(R.id.src))
.perform(click());
onData(hasToString(startsWith("CCD")))
.perform(click());
onView(withId(R.id.src))
.check(matches(withText(containsString("CCD"))));
Quello che sto cercando di fare è fare clic sulla voce nella Spinner
e verificare se è effettivamente selezionato nella Spinner
.
Ma sto ottenendo questo errore:
android.support.test.espresso.base.DefaultFailureHandler$AssertionFailedWithCauseError: 'with text: a string containing "CCD"' doesn't match the selected view. Expected: with text: a string containing "CCD" Got: "AppCompatSpinner{id=2131558533, res-name=src, visibility=VISIBLE, width=528, height=163, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1}"
Nella documentazione di prova spresso mostrano una soluzione per selezionare una voce all'interno del filatore dalla sua posizione di indice che penso è nel modo giusto ... URL: https://github.com/vgrec/EspressoExamples/blob/master/app/src/androidTest/java/com/vgrec/espressoexamples/SpinnerSelectionTest.java –