Espresso 测试调用视图按钮点击等待调用 api 响应数据progressDialog dimission [英] Espresso Testing call view button click waiting after call api response data progressDialog dimission
问题描述
我使用 via 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
推荐答案
view button click Waiting for progressdialog dimission using Thread.sleep(4000) sometime is going to right but some time is still show like the question error "Could not launch intent Intent".我想知道哪些想法比我的答案更好.
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 测试调用视图按钮点击等待调用 api 响应数据progressDialog dimission的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!