Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test with espresso with "hasTextColor"

How can I make a espresso test with the color of the text? Currently use hasTextColor():

onView(withId(R.id.editText)).check(matches(hasTextColor(Color.BLACK)));

But the error occurs:

android.content.res.Resources$NotFoundException: Resource ID #0xff000000 at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:195)

...

Details:

<EditText
 android:id="@+id/editText"
 android:textColor="#ff000000"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:layout_marginTop="48dp"/>
like image 230
Roberto Pinheiro Avatar asked Nov 21 '17 13:11

Roberto Pinheiro


People also ask

How do you do the espresso test?

To start recording a test with Espresso Test Recorder, proceed as follows: Click Run > Record Espresso Test. In the Select Deployment Target window, choose the device on which you want to record the test. If necessary, create a new Android Virtual Device.

What is Espresso UI Test?

Espresso is a UI test framework (part of the Android Testing Support Library) that allows you to create automated UI tests for your Android app.

What is matcher in espresso?

A matcher that allows for a quick creation of a matcher that applies to a given type but only processes items of a specific subtype of that matcher. BoundedMatcher. Some matcher sugar that lets you create a matcher for a given type but only process items of a specific subtype of that matcher.


1 Answers

You need to check against a color defined in the resources like hasTextColor(R.color.red)

It's also written in the documentation link you provided: colorResId : int

like image 160
chrjs Avatar answered Oct 27 '22 20:10

chrjs