title: Espresso can't find a view: NoMatchingViewException
body: <p>In my app,I have two fragments attached in an activity. Each fragment contains different views.</p>
  
  <p>The first one has two edit text fields and two buttons,where the user can login or register. So now I want to apply some Espresso testing. </p>
  
  <pre><code>@RunWith(AndroidJUnit4.class)
  public class LoginTest {
  @Rule
  public final ActivityRule&lt;MainActivity&gt; main = new ActivityRule&lt;&gt;   
  (MainActivity.class);
  
  @Test
  public void shouldBeAbleToFindViewsOfLoginScreen(){
      onView(withText(R.id.user_name)).perform(click());
     }
  
   }
  </code></pre>
  
  <p>However the test complains that it can not find the view with the id of R.id.user_name.</p>
  
  <pre><code>android.support.test.espresso.NoMatchingViewException: No views in hierarchy    
  found matching: with string from resource id: &lt;2131493050&gt;[user_name] value:    
  false
  </code></pre>
  
  <p>I use the corrent id as I checked from the uiautomatorviewer as well.</p>
  
  <p>The xml code for this fragment is</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:id="@+id/fragmentLogin"
  tools:context="team.football.ael.MainActivity"
  android:background="@drawable/background"&gt;
  &lt;include
  
      android:id="@+id/toolbar"
      layout="@layout/tool_lay"
  
      /&gt;
  
  &lt;LinearLayout
      android:padding="20dp"
      android:background="@drawable/roundedlayout"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true"
      android:layout_width="wrap_content"
      android:orientation="vertical"
      android:layout_height="wrap_content"&gt;
      &lt;ImageView
          android:src="@mipmap/ael_logo"
          android:layout_width="60dp"
          android:layout_height="60dp"
          android:layout_gravity="center_horizontal" /&gt;
      &lt;android.support.design.widget.TextInputLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_marginTop="10dp"&gt;
      &lt;EditText
          android:id="@+id/user_name"
          android:hint="@string/login_username"
          android:textColor="#fff"
          android:textColorHint="#fff"
          android:layout_width="250dp"
          android:layout_height="wrap_content" /&gt;
      &lt;/android.support.design.widget.TextInputLayout&gt;
      &lt;android.support.design.widget.TextInputLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_marginTop="10dp"&gt;
      &lt;EditText
          android:id="@+id/user_pass"
          android:textColorHint="#fff"
          android:layout_width="250dp"
          android:layout_height="wrap_content"
          android:inputType="textPassword"
          android:layout_marginTop="20dp"
          android:hint="κωδικός"
          android:textColor="#fff"
  
          /&gt;
      &lt;/android.support.design.widget.TextInputLayout&gt;
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"&gt;
  
          &lt;Button
              android:id="@+id/loginButton"
              android:layout_gravity="center_horizontal"
              android:text="Εισοδος"
              android:layout_marginTop="20dp"
              android:layout_width="0dp"
              android:layout_weight="1"
              android:textColor="#fff"
              android:background="@drawable/roundbutton"
              android:layout_height="wrap_content"
              android:onClick="userLogin"/&gt;
  
          &lt;Button
              android:layout_marginTop="20dp"
              android:layout_gravity="center_horizontal"
              android:text="Εγγραφη"
              android:textColor="#fff"
  
              android:layout_width="0dp"
              android:layout_marginLeft="10dp"
  
              android:background="@drawable/roundbutton"
  
              android:onClick="userReg"
              android:layout_weight="1"
              android:layout_height="wrap_content" /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;TextView
          android:textStyle="bold|italic"
          android:textSize="25sp"
          android:layout_gravity="center_horizontal"
          android:text="Ξέχασες τον κωδικό σου?"
          android:id="@+id/forgotPass"
          android:textColor="#fff"
  
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>Any ideas?</p>
  
  <p>Thanks.</p>