Espresso Testing call view button click waiting after call api response data progressDialog dimission

前端 未结 2 705
感动是毒
感动是毒 2021-01-28 16:40

I develop automation testing using via espresso library. Sometime I ever got error message \"Could not launch intent Intent\" when running test is make long time I call view b

2条回答
  •  臣服心动
    2021-01-28 17:18

    This probably happens when there is a progress dialog after test finishes. So your next test can't launch itself when progress dialog is active. You can prevent this by waiting progress dialog to end.

    onView(allOf(withId(R.id.btnWorkingDate), withText("OPEN DAY"))).check(matches(isDisplayed())).perform(click(),closeSoftKeyboard());
    long timeout = 0L;
    while(timeout < YOUR_DESIRED_TIMEOUT) {
    try {
        onView(withId(anIdInNextScreenAfterProgressDialog)).check(matches(isDisplayed));
        break;
    } catch (Exception e) {
       Thread.sleep(1000L);
       timeout += 1000L
    }
    

    This will wait until your progress bar disappears since it waits for something in the next page

提交回复
热议问题