我试图断言文本不在 View 中。
//ViewInteraction appCompatTextView10 = onView(
allOf(withText("Politics"), not(isDisplayed())));
appCompatTextView10.perform(click());//
不工作。
onView(allOf(withId(R.id.title), not(withText("Politics"))));
也不行。
有什么帮助吗?不推荐使用 doesnotexists() 吗?我无法使用它。
最佳答案
尝试:
onView(withText("Politics")).check(matches(not(isDisplayed())));
如果 View 层次结构中不存在该 View ,请改用它:
onView(withText("Politics")).check(doesNotExist());
关于Android Espresso 断言问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40257143/