Issue
I'm starting to play with Espresso, got my basic tests running. Now trying to figure out how to check that my edit text has a specific hint text? Thanks.
onView(withId(R.id.locationInput)).check(matches...?)
Solution
Looks like I figured it out. Basically, you need to create your own matcher:
public static Matcher<View> withHint(final String expectedHint) {
return new TypeSafeMatcher<View>() {
@Override
public boolean matchesSafely(View view) {
if (!(view instanceof EditText)) {
return false;
}
String hint = ((EditText) view).getHint().toString();
return expectedHint.equals(hint);
}
@Override
public void describeTo(Description description) {
}
};
}
Then you can use it:
onView(withId(R.id.locationInput)).check(matches(withHint("Location (Optional)")));
Answered By - Eduard
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.