vendredi 21 octobre 2016

NoMatchingViewException in Espresso at various time on emulator

I'm writing automated tests for my Android applications, and so far then run smoothly on three different Samsung tablets, but they have to run on an emulator.

When I run it on an emulator (Bluestacks, Android x86 Virtualbox), I get NoMatchingViewException on different views, meaning it's not on the same view every time. It typically shows up, when I open a dialog, press OK so it closes and then have to click on a view afterwards.

I have tried to put in isCompletelyDisplayed() as a viewmatcher. I am also capable of looping the test multiple times before it fails (my record is 6 times).

I think it has something do to with the emulator running much faster than my device, but shouldn't Espresso handle this with thread sync? Any ideas on why it's only a problem on emulator and how to fix this?

I have android.support.test.runner.AndroidJUnitRunner as test runner and uses Espresso 2.2.2.

Example of a line of code from a view (among others) that causes the problem

onView(allOf(isCompletelyDisplayed(),withId(R.id.mySpinner))).check(matches(isCompletelyDisplayed())).perform(click());

Aucun commentaire:

Enregistrer un commentaire