I don't think this is possible, depending on what you want exactly, I would use a custom socket:
public static Matcher<View> hasNoErrorText() { return new BoundedMatcher<View, EditText>(EditText.class) { @Override public void describeTo(Description description) { description.appendText("has no error text: "); } @Override protected boolean matchesSafely(EditText view) { return view.getError() == null; } }; }
This mate can check for errors in the TextText editor, use it as follows:
onView(allOf(withId(R.id.edittext), isDisplayed())).check(matches(hasNoErrorText()));
source share