[英]Espresso - how can you perform an OR ( || ) check?
I need only one of these two espresso checks to pass.我只需要通过这两项浓缩咖啡检查中的一项即可。 How can I achieve this?
我怎样才能做到这一点? If either of these
ViewAssertion
s pass, I will be happy.如果这些
ViewAssertion
的任何一个通过,我都会很高兴。
onView(withId(R.id.mainview))
.check(
matches(not(isDisplayed()))
)
or或者
onView(withId(R.id.mainview))
.check(
doesNotExist()
)
This isn't the best method but it'll work.这不是最好的方法,但它会起作用。 Ideally you should use a custom view matcher... but we're all lazy.
理想情况下,您应该使用自定义视图匹配器...但我们都很懒惰。
try {
// See if view is displayed
onView(withId(R.id.mainview))
.check(
matches(not(isDisplayed()))
);
}
catch (NoMatchingViewException e){
// Otherwise check it doesn't exist
onView(withId(R.id.mainview))
.check(
doesNotExist()
);
}
我认为您唯一的选择是自定义匹配器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.