I’m writing automated tests for my company’s app. The tests use a combination of Espresso and Robotium. Several of those tests are supposed to check whether certain
ReactImageView elements are displaying a specific image.
I first tried using
hasBackground() as follows:
However, this returns a
I then tried Daniele Bottillo’s matcher as described here: https://medium.com/@dbottillo/android-ui-test-espresso-matcher-for-imageview-1a28c832626f
onView(allOf(..., new DrawableMatcher(R.drawable....), isDisplayed())).check(matches(isDisplayed()));
But this didn’t work either:
java.lang.ClassCastException: com.facebook.drawee.generic.RootDrawable cannot be cast to android.graphics.drawable.BitmapDrawable
Lastly, I tried Frankie Sardo’s solution: Android Espresso match BitmapDrawables with different tint
onView(allOf(..., withImageDrawable(R.drawable...), isDisplayed())).check(matches(isDisplayed()));
However, this again throws a
NoMatchingViewException. I’m running out of ideas. Is it even possible to check what resource is attached to an image view?