Test with espresso with "hasTextColor"
Asked Answered
A

1

6

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"/>
Acetylide answered 21/11, 2017 at 13:18 Comment(0)
S
6

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

Secede answered 21/11, 2017 at 13:22 Comment(1)
Would you know how to get EditText's font size? I have an open question about this, could you help me? #47399159Acetylide

© 2022 - 2024 — McMap. All rights reserved.