Issue
I have a suite of Espresso tests that run on Android. They generally run without issue. However, intermittently, they fail to validate date in a Spinner. By looking in to it I found out that somehow the Spinner is being dismissed as soon as it is tapped.
The code that is running is:
public static void selectFromComboBox(String prompt, String toSelect) {
onView(allOf(withId(R.id.combo_box_entry), hasSibling(withText(prompt)))).perform(click());
onData(Matchers.allOf(is(instanceOf(String.class)), is(toSelect))).perform(click());
}
When I run the exact same test with no changes, I sometimes get the error
android.support.test.espresso.PerformException: Error performing 'load adapter data' on view 'is assignable from class: class android.widget.AdapterView'.
I recorded the screen for both passes and fails and found that on the failures, the list for the Spinner is being dismissed almost as soon as it is opened which appears to be what is causing the problem.
Log output doesn't actually look any different between the pass scenarios and the fail scenarios. Has anybody seen this before or know of a work around or have any idea just what the heck is going on?
Solution
Not the prettiest solution but the way I worked around this was by adding a simple 500 ms wait after opening the menu
Answered By - souch3
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.