gpt4 book ai didi

android - matches(not(isDisplayed())) 失败并出现 NoMatchingViewException

转载 作者:行者123 更新时间:2023-12-03 05:21:24 25 4
gpt4 key购买 nike

我正在尝试测试 UI View 的缺失。 View 选择器如下:

public static ViewInteraction onMyTestUi() {
return onView(withId(R.id.myTestId));
}

选择器可以正常检查 View 是否显示,但在检查 View 是否未显示时会出错。我的使用方法如下:

 onMyTestUi().check(matches(not(isDisplayed())));

但我收到以下错误:

com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException:No views in hierarchy found matching: with id: is Ifthe target view is not part of the view hierarchy, you may need to useEspresso.onData to load it from one of the followingAdapterViews:android.widget.ListView{...}

这很奇怪。我正在检查用户界面是否缺失,预计不会找到该 View 。那么为什么 Espresso 会抛出错误呢?请提出这里可能出现问题的建议。

最佳答案

需要使用doesNotExist()代替。找到here .

如果 View 位于 View 层次结构中,但处于不可见状态(可见性设置为“INVISIBLE”),请使用 not(isDisplayed)。但是,如果 View 根本不存在于 View 层次结构中(例如,可见性设置为“GONE”),则使用 doesNotExist()

关于android - matches(not(isDisplayed())) 失败并出现 NoMatchingViewException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28431647/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com