title: Android Espresso wait for text to appear
body: <p>I am trying to automate an Android app that is a chatbot using Espresso. I can say that I am completely new to Android app automation.
  Right now I am struggled with waiting. If I use <code>Thread.sleep</code>, it works perfectly fine. However, I would like to wait until a specific text appears on the screen. How can I do that?</p>
  <pre><code>@Rule
  public ActivityTestRule&lt;LoginActivity&gt; mActivityTestRule = new ActivityTestRule&lt;&gt;(LoginActivity.class);
  
  @Test
  public void loginActivityTest() {
  ViewInteraction loginName = onView(allOf(withId(R.id.text_edit_field),
  childAtPosition(childAtPosition(withId(R.id.email_field),0), 1)));
  loginName.perform(scrollTo(), replaceText(&quot;test@test.test&quot;), closeSoftKeyboard());
  
  ViewInteraction password= onView(allOf(withId(R.id.text_edit_field),
  childAtPosition(childAtPosition(withId(R.id.password_field),0), 1)));
  password.perform(scrollTo(), replaceText(&quot;12345678&quot;), closeSoftKeyboard());
  
  ViewInteraction singInButton = onView(allOf(withId(R.id.sign_in), withText(&quot;Sign In&quot;),childAtPosition(childAtPosition(withId(R.id.scrollView), 0),2)));
  singInButton .perform(scrollTo(), click());
  
  //Here I need to wait for the text &quot;Hi ...&quot;
  </code></pre>
  <p>Some explanations: after pressing the sign in button, the chatbot says &quot;Hi&quot; and gives some more information. I would like to wait for the last one message to appear on the screen.</p>