jeudi 24 août 2017

Espresso AppNotIdleException on Spinner (Error performing 'single click - At Coordinates: X, X and precision: X, X on view)

I have a layout with a Spinner and I am trying to select a value from it in an Espresso test. However I receive the following Exception:

Caused by: android.support.test.espresso.AppNotIdleException: Looped for 24542 iterations over 60 SECONDS. The following Idle Conditions failed .

I have searched online and it appears this can happen when the app is not idle due to another process or animation, which is possible since I hide a progress bar (set its visibility to GONE) before rendering the layout.

However, the really strange part is I have a similar test that does not fail. The only thing I can think of is the test that DOES fail, the Spinner dropdown takes up most of the width of the screen, whereas the one that passes doesn't. I have tried all sorts of ways to click on the Spinner and I cannot get it to work.

This is how I am selecting the value in the Spinner, but it fails on the first line in this one test:

    onView(allOf(withId(spinnerId), withParent(withId(parentRowLayoutId)))).perform(click());
    onView(allOf(withId(dropdownListItemLayoutId), isDisplayed(), hasDescendant(withText(textToClick)))).perform(click());

I can confirm the dropdown is displayed when the first line of code above is executed in the emulator, but it just hangs and doesn't proceed to the next line of code. All animations are turned off on the emulator. Any ideas what I am doing wrong?

Aucun commentaire:

Enregistrer un commentaire