你能帮我解决这个问题吗?我正在写一个浓咖啡测试。这是代码:
onView(ViewMatchers.withId(R.id.btnControl1)).perform(click());
SystemClock.sleep(delay);
onView(ViewMatchers.withId(R.id.btnControl2)).perform(click());
SystemClock.sleep(delay);
onView(ViewMatchers.withId(R.id.btnControl3)).perform(click());
SystemClock.sleep(delay);
我想循环它。例如:单击这3个按钮20次。
提前致谢!
答案 0 :(得分:2)
你可以把它放在for循环中:
for (int i = 0; i < 20; i++) {
onView(ViewMatchers.withId(R.id.btnControl1)).perform(click());
SystemClock.sleep(delay);
onView(ViewMatchers.withId(R.id.btnControl2)).perform(click());
SystemClock.sleep(delay);
onView(ViewMatchers.withId(R.id.btnControl3)).perform(click());
SystemClock.sleep(delay);
}