mercredi 29 août 2018

Espresso testing on Android API 28 emulator click issue

This is only on Android devices with api level 28. trying to match a text after clicking the spinner fails.

Two approaches, one looking for a window that is not the activity, the second is looking for popup menu:

...
    // Look for text "Green" in the menu
    onView(withId(getFieldId(COLOR_ID))).perform(click());
    onView(withText("Green"))
            .inRoot(withDecorView(not(is(rule.getActivity().getWindow().getDecorView())))) // Look for popup menu
            .perform(click());

    // Second spinner, Look for the text "Medium"
    onView(withId(getFieldId(SIZE_ID))).perform(click());
    onView(withText("Medium")).inRoot(RootMatchers.isPlatformPopup()).perform(click());
...

Both are working fine with devices API <=27

Any idea why this is not working on 28? Thank you.

Aucun commentaire:

Enregistrer un commentaire