androidandroid-espressoandroid-testingbarista

Espresso can't click displayed view


Overnight my ui tests stopped working all of a sudden:

Line in barista clickOn(R.id.myView) throws:

com.schibsted.spain.barista.internal.failurehandler.BaristaException: Could not perform action single click on view with id: [...]   
[...]   
Caused by: androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching: (is displayed on the screen to the user and with id: [...]

Line in Espresso onView(withId(R.id.myView)).perform(scrollTo(), click()) throws:

androidx.test.espresso.PerformException: Error performing 'single click - At Coordinates: 53, 1723 and precision: 16, 16' on view 'Animations or transitions are enabled on the target device.  
[...]   
Caused by: java.util.NoSuchElementException: List is empty.

I don't understand why this happens. I can see the view on screen during the test and espresso gave me some coordinates.

Edit:
Since it's a TextView I also tried Baristas clickOn(context.getString(R.string.myText)) but it throws:

com.schibsted.spain.barista.internal.failurehandler.BaristaException: Could not perform action single click on view with text: is [...]  
[...]   
Caused by: androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching: (is displayed on the screen to the user and with text: is [...]
<TextView
   android:id="@+id/myView"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:text="@string/myText"/>

Solution

  • The error is unrelated to Espresso or Barista.
    java.util.NoSuchElementException: List is empty was thrown in the OnClickListener of the view.