Espresso claims that there is no need for Thread.sleep()
but my code doesn't work unless I include it. I am connecting to an IP and, while connecting, a progress dialog is shown. I need a Thread.sleep()
call to wait for the dialog to dismiss. This is my test code where I use it:
IP.enterIP(); // fills out an IP dialog (this is done with espresso)
//progress dialog is now shown
Thread.sleep(1500);
onView(withId(R.id.button).perform(click());
I have tried this code without the Thread.sleep()
call but it says R.id.Button
doesn't exist. The only way I can get it to work is with the Thread.sleep()
call.
Also, I have tried replacing Thread.sleep()
with things like getInstrumentation().waitForIdleSync()
and still no luck.
Is this the only way to do this? Or am I missing something?
Thanks in advance.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…