I am creating an espresso test for bottom sheet where the sheet has 5 linearly arranged textview and the first textview is visible and clicking the first textview will expand the entire bottom sheet revealing all the items, and then the third item is needed to be clicked for the test to pass.
The problem is that espresso doesn't click the textview of the bottom sheet after expanding until I put a Thread.sleep(1000)
.
I even tried IdlingResource, I set it to false once the click is registered on the first item and after the onStateChanged is called on bottomSheetBehaviour I set it to true again but still no help.
This doesn't work :
onView(withId(R.id.toolsItem1)).perform(click());
onView(withId(R.id.toolsItem3)).check(matches(isDisplayed()));
onView(withId(R.id.toolsItem3)).perform(click());
This does :
onView(withId(R.id.toolsItem1)).perform(click());
Thread.sleep(1000);
onView(withId(R.id.toolsItem3)).check(matches(isDisplayed()));
onView(withId(R.id.toolsItem3)).perform(click());