How could be possible to click on EditText\'s right drawable (check the screenshot)? I have tried several ways but I always get stuck.
public static Matcher
For people that have this problem right now as of 1/7/2021 (European format). I had the same problem and solved it like this:
In your xml, maybe you have something like this:
As you saw the above xml code, i added app:endIconContentDescription="clear text"
.
grab from the xml, app:endIconContentDescription="clear text"
and add onView(withContentDescription("clear text")).perform(click());
in your Instrumented test method, in your test class, like:
@Test
public void testEdittext(){
onView(withId(R.id.eddittext)).perform(typeText("Type something."));
onView(withContentDescription("clear text")).perform(click());
}
Forgot to say that this onView(withId(R.id.note_title)).perform(typeText("Type something."));
is the line that you must first write something in the edittext, so that the end icon(eddittext's right drawable) will show up and then click it.