Scroll down in navigation menu using espresso

1.5k Views Asked by At

I've a navigation menu in my application, I wanna to click on an item inside but I should scroll down in navigation menu to reach the item. Espresso recorder didn't detect the scroll/swipe action I made on the screen, it just detected the click action on the item.

ViewInteraction appCompatCheckedTextView = onView(
                allOf(withId(R.id.resourceid), withText("Settings"), isDisplayed()));
        appCompatCheckedTextView.perform(click());

How can I implement the swipe / scroll action in navigation menu?

2

There are 2 best solutions below

1
On BEST ANSWER

If you are using Recorder to Swipe/Scroll. It is not supported on Android Studio recorder as yet. Please follow this link for future updates:

Weblink: Issue 235615 in android Studio

2
On

I solved it down by getting the resource id of navigation drawer and swipe up inside it.

ViewInteraction viewInteraction = onView(withId(R.id.nav_bar)).perform(swipeUp());

I added it before the above code and it worked.