I'm trying to write an espresso function to match the first element espresso finds according to my function, even when multiple matching items are found.
Ex:
I have a list view with cells which contain item price. I want to be able to switch the currency to Canadian dollars and verify item prices are in CAD.
I'm using this function:
onView(anyOf(withId(R.id.product_price), withText(endsWith("CAD"))))
.check(matches(
isDisplayed()));
This throws the AmbiguousViewMatcherException.
In this case, I don't care how many or few cells display CAD, I just want to verify it is displayed. Is there way to make espresso pass this test as soon as it encounters an object meeting the parameters?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…