Basically I am trying to test that after login incorrectly I have an error showing in the email field.
The view is:
This works with a CustomMatcher:
public static Matcher hasTextInputLayoutErrorText(final String expectedErrorText) {
return new TypeSafeMatcher() {
@Override
public boolean matchesSafely(View view) {
if (!(view instanceof TextInputLayout)) {
return false;
}
CharSequence error = ((TextInputLayout) view).getError();
if (error == null) {
return false;
}
String hint = error.toString();
return expectedErrorText.equals(hint);
}
@Override
public void describeTo(Description description) {
}
};
}