2016-02-04 1 views
0

J'ai un Spinner avec diverses options. Après avoir cliqué sur une option, un fragment est chargé dans une FrameLayout de l'activité. Avec Espresso, je sélectionne et clique sur un élément Spinner sans erreur, mais après cela, la hiérarchie de vues contient uniquement le spinner PopupViewContainer et je ne peux sélectionner aucune vue dans mon activité.Espresso: Après avoir cliqué sur un élément spinner, afficher la hiérarchie contient uniquement le spinner PopupViewContainer

Mon code de test est la suivante:

onView(withId(R.id.pager)).perform(swipeLeft()).perform(swipeLeft()); 
onView(withId(R.id.fgs_cbx_scan_type)).perform(click()); 
onData(hasToString(startsWith(GreenScanType.ARRIVAL.getName()))).inAdapterView(withId(R.id.fgs_cbx_scan_type)).perform(click()); 

//So far so good with no errors. Then the following call fails 
//because the view hierarchy does not contain the hierarchy 
//of the activity anymore but just the popup of the spinner. 
onView(withId(R.id.fgs_cbx_scan_type)).check(matches(withText(containsString(GreenScanType.ARRIVAL.getName())))); 

Y at-il quelque chose que je manque ou faire du tort?

Répondre

0

Finalement, je devais appeler aussi

onView(withText(GreenScanType.ARRIVAL.getName())).perform(click()); 

après onData