I am writing some espressos for an application that I recently made. I am using NavigationView inside DrawerLayout as a sliding menu.
I managed to open the box this way:
onView(withId(R.id.drawer_layout)).perform(open());
Now this works, so I'm trying to click on a menu item in the NavigationView.
onView(withId(R.id.nav_register))..
can't find a representation. I tried a few things, but I can not find a way to get the menuitem idea. So the elements in the code are assigned:
<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" />
and activity_main_drawer.xml
<group android:checkableBehavior="single"> <item android:id="@+id/nav_home" android:icon="@drawable/ic_menu_home" android:title="Home" /> <item android:id="@+id/nav_register" android:icon="@drawable/ic_menu_register" android:title="Registreer" /> <item android:id="@+id/nav_login" android:icon="@drawable/ic_menu_login" android:title="Log in" /> <item android:id="@+id/nav_play" android:icon="@drawable/ic_menu_play" android:title="Speel sessie" /> <item android:id="@+id/nav_logout" android:icon="@drawable/ic_menu_logout" android:title="Log uit" /> </group>
I read something about NavigationViewMenuItem is a private member and not available. Can someone help me?
Congratulations! Shenno
source share