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.
@RunWith(AndroidJUnit4.class)
@LargeTest
public class AuthorizationTest {
private IdlingResource mIdlingResource;
@Rule
public ActivityTestRule<AuthorizationActivity> mActivityRule = new ActivityTestRule(AuthorizationActivity.class);
@Before
public void SetUp() throws Exception {
Thread.sleep(4000);
try {
onView(allOf(withId(R.id.tiAuthLogin), (isDisplayed()))).check(matches(isDisplayed()));
} catch (NoMatchingViewException e) {
pressBack();
}
}
@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();
onView(isRoot()).perform(waitFor(40000));
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()));
}
}