Android espresso test NavigationView : <p>I am writing some espressotests for an appplication I recently made.
I'm using a NavigationView inside a DrawerLayout as sliding menu.</p>

<p>I managed to open the drawer this way:</p>

<pre><code>        onView(withId(R.id.drawer_layout)).perform(open());
</code></pre>

<p>This works so now I am trying to perform a click on a menuitem in the NavigationView. </p>

<pre><code>onView(withId(R.id.nav_register))..
</code></pre>

<p>can not find the view. I tried several things but I can't find a way to retrieve the menuitem view. This is the way the items are assigned in the code:</p>

<pre><code>    &lt;android.support.design.widget.NavigationView
    android:id="@+id/nav_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;
</code></pre>

<p>and activity_main_drawer.xml</p>

<pre><code>&lt;group android:checkableBehavior="single"&gt;
    &lt;item
        android:id="@+id/nav_home"
        android:icon="@drawable/ic_menu_home"
        android:title="Home" /&gt;
    &lt;item
        android:id="@+id/nav_register"
        android:icon="@drawable/ic_menu_register"
        android:title="Registreer" /&gt;
    &lt;item
        android:id="@+id/nav_login"
        android:icon="@drawable/ic_menu_login"
        android:title="Log in" /&gt;
    &lt;item
        android:id="@+id/nav_play"
        android:icon="@drawable/ic_menu_play"
        android:title="Speel sessie" /&gt;
    &lt;item
        android:id="@+id/nav_logout"
        android:icon="@drawable/ic_menu_logout"
        android:title="Log uit" /&gt;
&lt;/group&gt;
</code></pre>

<p>I read something about NavigationViewMenuItem is a private member and not accessible. Can someone help me out?</p>

<p>Greets!
Shenno </p>
