title: Android : Second Navigation View is not recognized by Espresso
body: <p>I am using two Navigation View in my app, second ( right ) one is via a custom component. Its working fine during manual testing, however espresso doesn't recognize it during testing. Second NAV is kept invisible and activated it onCreate method of corresponding method. </p>
  
  <p>I tried to test first navigation view using same appraoch, it works fine.. </p>
  
  <p>Below is relevant code snippets and logs </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v4.widget.DrawerLayout   
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:id="@+id/drawer_layout"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:fitsSystemWindows="true"
     tools:openDrawer="start"&gt;
  
      &lt;include
      layout="@layout/app_bar_main"
      android:layout_width="match_parent"
      android:layout_height="match_parent" /&gt;
  
     &lt;android.support.design.widget.NavigationView
      android:id="@+id/nav_left_view"
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:layout_gravity="start"
      android:fitsSystemWindows="true"
      app:headerLayout="@layout/nav_header_main"
      app:menu="@menu/activity_main_drawer" /&gt;
  
     &lt;com.example.tt0401.NavigationViewRight
      android:id="@+id/nav_right_view"
      android:layout_width="wrap_content"
      android:layout_height="600dp"
      android:layout_marginTop="80dp"
      android:layout_gravity="end"
      android:fitsSystemWindows="true"
      android:visibility="gone"
      app:itemBackground="@drawable/nav_item_selector"
      app:headerLayout="@layout/nav_header_right"
      app:menu="@menu/activity_right_drawer" /&gt;
  
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p>//code inside  onCreate(Bundle savedInstanceState) method to method to make it visible 
  <code>drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, navigationViewRight);</code></p>
  
  <p>//Espresso Test method </p>
  
  <pre><code>@Test
  public void navigationDrawer() throws Exception {
  fabAddClick();
  onView(withId(R.id.drawer_layout)).perform(DrawerActions.open(Gravity.END));
  onView(withId(R.id.nav_right_view)).perform(NavigationViewActions.navigateTo(1000003));
  }
  </code></pre>
  
  <p>Espresso Failure Logs</p>
  
  <p>01-02 12:25:58.228 18570-18585/? I/TestRunner: android.support.test.espresso.PerformException: Error performing 'click on menu item with id' on view 'with id: com.example.tt0401:id/nav_right_view'.
                                                     at android.support.test.espresso.PerformException$Builder.build(PerformException.java:83)
                                                     at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:80)
                                                     at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:56)
                                                     at android.support.test.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:184)
                                                     at android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:115)
                                                     at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:87)
                                                     at com.example.tt0401.RecordActivity3Test.navigationDrawer(RecordActivity3Test.java:135)
                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                     at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
                                                     at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
                                                     at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
                                                     at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
                                                     at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
                                                     at android.support.test.internal.statement.UiThreadStatement.evaluate(UiThreadStatement.java:55)
                                                     at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:270)
                                                     at org.junit.rules.RunRules.evaluate(RunRules.java:20)
                                                     at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
                                                     at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
                                                     at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
                                                     at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
                                                     at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
                                                     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
                                                     at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
                                                     at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
                                                     at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
                                                     at org.junit.runners.Suite.runChild(Suite.java:128)
                                                     at org.junit.runners.Suite.runChild(Suite.java:27)
                                                     at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
                                                     at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
                                                     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
                                                     at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
                                                     at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
                                                     at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
                                                     at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
                                                     at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
                                                     at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:59)
                                                     at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:262)
                                                     at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1932)
                                                  Caused by: java.lang.RuntimeException: Action will not be performed because the target view does not match one or more of the following constraints:
                                                 (is assignable from class: class android.support.design.widget.NavigationView and view has effective visibility=VISIBLE and at least 90 percent of the view's area is displayed to the user.)
                                                 Target view: "NavigationViewRight{id=2131624075, res-name=nav_right_view, visibility=INVISIBLE, width=980, height=2100, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=1440.0, y=0.0, child-count=1}"
                                                     at android.support.test.espresso.ViewInteraction$1.run(ViewInteraction.java:138)
                                                     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
                                                     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                  at androi
  01-02 12:25:58.228 18570-18585/? I/TestRunner: ----- end exception -----
  01-02 12:25:58.231 18570-18585/? I/TestRunner: finished: navigationDrawer(com.example.tt0401.RecordActivity3Test)
  01-02 12:25:58.250 18570-18585/? I/TestRunner: run finished: 1 tests, 1 failed, 0 ignored</p>