android – openDrawer from espresso contrib is deprecated-ThrowExceptions

Exception or error:

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

then how should I open a drawer?

How to solve:

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());

###

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)

###

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());

Leave a Reply

Your email address will not be published. Required fields are marked *