【问题标题】:openDrawer from espresso contrib is deprecatedespresso contrib 中的 openDrawer 已弃用
【发布时间】:2015-09-18 14:30:40
【问题描述】:

Espresso contrib (com.android.support.test.espresso:espresso-contrib:2.2.1) openDrawer 方法已弃用

那我应该怎么打开抽屉呢?

【问题讨论】:

    标签: android open-source automated-tests android-testing android-espresso


    【解决方案1】:

    这是一个关于如何使用新的openclose 方法的示例:

    onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());

    onView(withId(R.id.drawer_layout)).perform(DrawerActions.close());

    【讨论】:

    • 我有以下问题,在使用这些行打开抽屉后,下一个操作,即单击抽屉内的项目,由于抽屉立即关闭而失败。之后没有其他操作会导致抽屉关闭的原因是什么?
    【解决方案2】:

    openDrawer 的文档建议使用具有正确资源 ID 的 open 方法并执行 ViewAction

    在匹配视图后使用 open() 和 perform。这种方法将 在下一版本中删除。


    http://developer.android.com/reference/android/support/test/espresso/contrib/DrawerActions.html#open(int)

    【讨论】:

      【解决方案3】:

      你可以试试这个!这将从工具栏获取菜单,然后点击他

      onView(allOf(withContentDescription("Menu"),
                   withParent(withId(R.id.toolbar)),
                   isDisplayed())).perform(click());
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-02-12
        • 1970-01-01
        • 2022-07-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多