Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a delay on click button with Esspresso tests

I'm really new with esspresso issues and I have a little question, I need to emulate that users click on a button, tree times, but with some delay. A Human, takes some time to click a button, maybe with one second delay.

Whats the better way to made that on an esspresso test? othere frameworks have sleep, and so on... but I think that espresso hasen't. Any idea?

--Edited: I made this, but don't know if it's correct:

try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

Another way, but more clear, if you don't use thread.interrupt() is this:

SystemClock.sleep(millis)
like image 404
jfcogato Avatar asked Nov 30 '22 11:11

jfcogato


1 Answers

for (int = i; i < numOfClicks; i++) {
  onView(<matcher for your view>).perform(click());
  SystemClock.sleep(1000);
}
like image 100
ValeraZakharov Avatar answered Dec 04 '22 12:12

ValeraZakharov