Testing background color espresso Android

前端 未结 7 923
灰色年华
灰色年华 2020-12-11 14:50

Is it possible to check if the background color matches a given color with espresso?

Update:

I made a custom matcher, similar to what @Irfa

7条回答
  •  無奈伤痛
    2020-12-11 15:36

    Another approach to check TextView text's color could be via hasTextColor(int color) as it comes directly from Espresso.

    import static android.support.test.espresso.matcher.ViewMatchers.hasTextColor;
    
    onView(withId(R.id.anyTextView)).check(matches(hasTextColor(R.color.red)));
    

    Be aware that this method is currently in Beta for Espresso 3.0.1

提交回复
热议问题