title: Espresso: Thread.sleep( )
body: <p>Espresso claims that there is no need for <code>Thread.sleep()</code> 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 <code>Thread.sleep()</code> call to wait for the dialog to dismiss. This is my test code where I use it:</p>
  <pre><code>    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());
  </code></pre>
  <p>I have tried this code without the <code>Thread.sleep()</code> call but it says <code>R.id.Button</code> doesn't exist. The only way I can get it to work is with the <code>Thread.sleep()</code> call.</p>
  <p>Also, I have tried replacing <code>Thread.sleep()</code> with things like <code>getInstrumentation().waitForIdleSync()</code> and still no luck.</p>
  <p>Is this the only way to do this? Or am I missing something?</p>
  <p>Thanks in advance.</p>