Espresso Testing调用视图按钮在调用api响应数据进度之后单击等待对话框退出 [英] Espresso Testing call view button click waiting after call api response data progressDialog dimission

查看:117
本文介绍了Espresso Testing调用视图按钮在调用api响应数据进度之后单击等待对话框退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过espresso库开发自动化测试.有时候我 运行测试时收到错误消息无法启动意图" 在API响应数据进度对话框发送之后,我叫了很长时间,我叫view btn click.请为我提供一些通过意式浓缩咖啡技术进行自动化测试的错误提示,谢谢:D

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 btn click after api response data progress-dialog dimission. Please help me something ideas for those error who have experience automation testing using via espresso technic Thanks :D

推荐答案

单击查看按钮单击使用Thread.sleep(4000)等待进度对话",虽然有时是正确的,但有时仍会显示类似问题错误无法启动意图的意图" ".我想知道哪些想法比我的答案更好.

view button click Waiting for progressdialog dimission using Thread.sleep(4000) sometime is going correct but sometime is still show like the question error "Could not launch intent Intent". I would like to know which ideas better than my answer.

ProgressDialog Utils Class the method

public void showProgressDialog() {
    if (mProgressDialog == null) {
        mProgressDialog = new ProgressDialog(this);
        mProgressDialog.setCancelable(false);
        mProgressDialog.setMessage("Loading...");
    }

    mProgressDialog.show();
}

public void hideProgressDialog() {
    if (mProgressDialog != null && mProgressDialog.isShowing()) {
        mProgressDialog.dismiss();
    }
}

测试

@Test
  public void test1() throws InterruptedException {
    //onView(withText("Loading")).check(matches(isDisplayed()));
    //    onView(allOf(isAssignableFrom(ProgressBar.class),withText("Loading..."))).check(matches(isDisplayed()));

    //onView(withId(R.id.btnWorkingDate)).perform(click());
  //  Intents.init();

    // override progress bar infinite animation with a simple image

    //onView(withText("Loading...")).check(matches(isDisplayed()));


  //  onView(withText("Loading...")).check(matches(not((isDisplayed()))));

    //onView(withText("Loading...")).check(matches(isDisplayed()));
   // onView(withText("Loading...")).check(matches(not(isDisplayed())));
   // assertTrue(progressBar().exists());

    try {
        onView(allOf(withId(R.id.btnWorkingDate), withText("OPEN DAY"))).check(matches(isDisplayed())).perform(click(),closeSoftKeyboard());
    }catch (NoMatchingViewException e) {
        // View is not in hierarchy
    }
    Thread.sleep(4000);
 /*   onView(allOf(withId(R.id.btnWorkingTime),withText("START SHIFT"), isDisplayed())).perform(click(),closeSoftKeyboard());

    onView(allOf(withId(R.id.btnWorkingTime),withText("END SHIFT"), isDisplayed())).perform(click(),closeSoftKeyboard());*/
 //   Intents.release();
   // intended(hasComponent(DashboardActivity.class.getName()));
    //assertNotNull(view);
    //onView(withId(R.id.btnWorkingDate)).perform(click());
}


@Test
public void test2() throws InterruptedException {

   // onView(allOf(withId(R.id.btnWorkingTime),withText("START SHIFT"), isDisplayed())).perform(click(),closeSoftKeyboard());

  //  assertTrue(progressBar().exists());

    try {
        onView(allOf(withId(R.id.btnWorkingTime), withText("START SHIFT"))).check(matches(isDisplayed())).perform(click(),closeSoftKeyboard());
    }catch (NoMatchingViewException e) {
        // View is not in hierarchy
    }

    Thread.sleep(4000);
}

@Test
public void test3() throws InterruptedException {

    try {
        onView(allOf(withId(R.id.btnWorkingTime), withText("END SHIFT"))).check(matches(isDisplayed())).perform(click(),closeSoftKeyboard());
    }catch (NoMatchingViewException e) {
        // View is not in hierarchy
    }
    Thread.sleep(5000);
}

这篇关于Espresso Testing调用视图按钮在调用api响应数据进度之后单击等待对话框退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆