Android:Espresso:无法检查未显示主页按钮

时间:2019-04-14 16:44:50

标签: android android-espresso

Android Studio 3.2

要检查的是显示主页按钮,我使用下一个测试(解决方法)

 @Test
    fun toolbar_homeButton_isDisplayed() {
        onView(withContentDescription(R.string.abc_action_bar_up_description))
                .check(matches(isDisplayed()))
    }

但是如何检查主页按钮不显示。

此测试失败:

@Test
    fun toolbar_homeButton_isNotDisplayed() {
        onView(withContentDescription(R.string.abc_action_bar_up_description))
                .check(matches(not(isDisplayed())))
    }

错误:

androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with content description from resource id: <2131623937>[abc_action_bar_up_description] value: Navigate up

View Hierarchy:
+>DecorView{id=-1, visibility=VISIBLE, width=1080, height=1920, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable

0 个答案:

没有答案