如何在浓缩咖啡测试中循环3个按钮

问题描述:

您能帮我解决这个问题吗?我正在撰写浓缩咖啡测试。这里是代码:如何在浓缩咖啡测试中循环3个按钮

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次。

在此先感谢!

你可以把它放在一个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); 
} 
+0

非常感谢,它的工作 – TLDima