Search code examples
androidandroid-5.0-lollipopandroid-4.0-ice-cream-sandwichandroid-testingandroid-espresso

Espresso action bar back stopped working in SDK 21


I have functional tests using mainly Espresso and running correctly. Yesterday I tried to migrate to Android 5 Lollipop. I ran the tests but all of the tests using this line of code stopped working on emulator with sdk 21:

onView(withContentDescription("Navigate up")).perform(click());

Maybe when I am back home I will try Robotium

getInstrumentation().runOnMainSync(new Runnable() {
        @Override
        public void run() {
            solo.clickOnActionBarHomeButton();
        }
});

Anybody found a solution that would work also in Android 4.x? Thank you in advance!


Solution

  • Answer created from comment:
    I use:

    onView(allOf(withText("text"), isDisplayed())).perform(click())
    

    and it works as expected.