Android – How to click on an item on a navigation drawer using Espresso?

public void clickOnYourNavigationItem_ShowsYourScreen() {
    // Open Drawer to click on navigation.
        .check(matches(isClosed(Gravity.LEFT))) // Left Drawer should be closed.
        .perform(; // Open Drawer

    // Start the screen of your activity.

    // Check that you Activity was opened.
    String expectedNoStatisticsText = InstrumentationRegistry.getTargetContext()

This does exactly what you are looking for.

Other examples are available here or here

Leave a Comment