有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java浓缩咖啡中是否有“或”运算符?

我对安卓浓缩咖啡测试有点陌生

我的问题是,我有一个名为SampleButton的视图交互,当我单击它时,我想检查另一个视图交互(TextResult)是否包含“clean”或“infected”字符串。所以预期的代码是这样的:

SampleButton.perform(click()); // SampleButton is View Interaction
ViewInteraction TextResult = onView(withId(R.id.inference_result)); // TextResult is also a View Interaction
TextResult.check(matches(withText("clean") or withText("infected"))) // THROWS AN ERROR

所以最后一行代码会抛出一个错误,这意味着它无法识别“或”操作

编辑:

经过更精确的搜索,结果如下:

TextResult.check(matches(withText(anyOf(is("infected") , is("clean")))));

通过使用anyOf和is,我们可以制作“或操作”

非常感谢您的帮助! 谢谢


共 (0) 个答案