openDrawer from espresso contrib is deprecated

谁说我不能喝 提交于 2019-12-03 16:22:20

问题


Espresso contrib (com.android.support.test.espresso:espresso-contrib:2.2.1) openDrawer method is deprecated

then how should I open a drawer?


回答1:


Here's an example on how to use the new open and close methods:

onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());

onView(withId(R.id.drawer_layout)).perform(DrawerActions.close());




回答2:


The documentation for openDrawer suggests using the open method with the correct resource id and perform ViewAction.

Use open() with perform after matching a view. This method will be removed in the next release.


http://developer.android.com/reference/android/support/test/espresso/contrib/DrawerActions.html#open(int)




回答3:


You can try this out! This will get the menu from toolbar, and press a click on him

onView(allOf(withContentDescription("Menu"),
             withParent(withId(R.id.toolbar)),
             isDisplayed())).perform(click());


来源:https://stackoverflow.com/questions/32654554/opendrawer-from-espresso-contrib-is-deprecated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!