jeudi 13 février 2020

How to make the Espresso test wait until the page loads

I will log in. After that, a request to display a list of cards. Each time this request occurs at a different time and using sleep() is not very good. How can I make the test wait as long as the page is loading? Preferably with sample code.

@Test
public void checkMoneyBackButton() throws Exception {
    onView(withId(R.id.btnAuthLogin)).perform(click());

    Thread.sleep(10000);
    onView(withId(R.id.etSessionKey1)).perform(typeText("1234"));
    closeSoftKeyboard();

    SystemClock.sleep(35000);


    ViewInteraction viewInteraction = Espresso.onView(withText("**** 0431"));
    viewInteraction.perform(click());

    Thread.sleep(3000);

    Espresso.onView(ViewMatchers.withId(R.id.vpCard)).perform(ViewActions.swipeUp());

    onView(withId(R.id.statementMoneyBack)).check(matches(isDisplayed()));
}

Aucun commentaire:

Enregistrer un commentaire