mardi 11 février 2020

Is there a way to make Espresso tests more stable?

I am writing Espresso test. Log in to the application. I enter the session key. Then I need to check for four elements on the page. But the test broke in 3 of 4 cases. Maybe this is because the code fires before the page has time to load. And if this is true, then how can this be avoided?

@Test
public void checkContentsCartsWindow() throws Exception {
    onView(withId(R.id.btnAuthLogin)).perform(click());
    Thread.sleep(3000);
    onView(withId(R.id.etSessionKey1)).perform(typeText("1234"));
    SystemClock.sleep(6000);
    onView(withId(R.id.menu_pfm)).check(matches(isDisplayed()));
    onView(withId(R.id.menu_more)).check(matches(isDisplayed()));
    onView(withId(R.id.fabOnboarding)).check(matches(isDisplayed()));
    onView(withId(R.id.fab)).check(matches(isDisplayed()));
}

Aucun commentaire:

Enregistrer un commentaire