Espresso Testing UI in androidTests Fails when run on Gradle ManagedDevice

36 Views Asked by At

I have a UI test that when I run it on an emulator or real device it works. When I run it on the gradle managed device it fails.

I have a list of items that I click on in NestedScrollView. About 2/3 of the way down if I click on, in emulator, that item and it shows a BottomSheetDialog. When gradle managed device clicks on it, it seems its clicking on the floating action button. I can only tell by the println I have were I print out the views hierarchy. I can tell it is on the next page that comes from the floating action button. I can't seem to take an image to confirm as Espresso does not have that ability just to snap a shot. Failed tests snapshots is not working for me either.

This is my one issues with google testing they make it next to impossible to have non-flaky UI tests and the hoops to jump to make them stable is not worth it to a lot of companies.

@Test
fun BasicSearch() {
    onView(withId(R.id.filter_1))
        .perform(WaitUntilViewIsEnabled(10000), click()) // this works
    homeFiltersBackButton()
    onView(withId(R.id.filter_8)).perform(click()) // this is the problem

Is there a way to maybe scroll an item to the middle of screen or to the top? I've tried many variations scrollTo, customScrollTo. I had to write another version of scrollTo since most of our stuff sits inside a Coordinator layout and has a NestedScrollingView in it.

we run the gradle managed device with this gradle command

./gradlew pixel2api31DebugAndroidTest

FYI can't use espresso recorder anymore since we have compose in the project. Anyway it was garbage spit out way more garbage and only worked half the time.

0

There are 0 best solutions below