multi matchs in espresso test android

Issue

I need to check view is display and is enabled.

  btn.check(matches(isDisplayed()))
            .check(matches(isEnabled()))

can I use an array for this?

for example:

 btn.check(matches(isDisplayed(),isEnabled()))

Solution

You can use allOf method which matches all of the specified matchers:

 btn.check(matches(allOf(isDisplayed(),isEnabled())))

Answered By – Saeed Masoumi

Leave a Comment