
我在DrawerLayout中使用NavigationVIEw作为滑动菜单.
我设法以这种方式打开抽屉:
onVIEw(withID(R.ID.drawer_layout)).perform(open());
这样做现在我正在尝试在NavigationVIEw中的menuitem上执行单击.
onVIEw(withID(R.ID.nav_register))..
找不到视图.我尝试了几件事,但我找不到检索menuitem视图的方法.这是在代码中分配项目的方式:
<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" />
和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>
我读过一些关于NavigationVIEwMenuItem的东西是私有成员而且无法访问.有人可以帮我吗?
映入眼帘!
Shenno
我建议你使用withText方法:
onVIEw(withText("the item Title")). 总结 以上是内存溢出为你收集整理的Android espresso测试NavigationView全部内容,希望文章能够帮你解决Android espresso测试NavigationView所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)