【问题标题】:Android Studio espresso test recorder - swipe eventsAndroid Studio espresso 测试记录器 - 刷卡事件
【发布时间】:2017-04-24 18:35:05
【问题描述】:

我一直在玩意式浓缩咖啡测试记录器和reading the documentation

文档说明:

与您的设备交互以开始记录事件,例如“点击”和 “类型”操作。

是否可以记录滑动事件,例如在视图寻呼机上滑动?虽然我知道它仍处于测试阶段,但我一直找不到任何这样做的例子。

谢谢

【问题讨论】:

    标签: android android-studio android-espresso android-testing android-espresso-recorder


    【解决方案1】:

    如今,Espresso 测试记录器缺乏滑动事件或从实际活动开始等功能。也许这会在最近的功能中修复。

    如今,编写 Espresso 测试更简单、更简单。

    这可能有用:https://google.github.io/android-testing-support-library/downloads/espresso-cheat-sheet-2.1.0.pdf

    希望它会有所帮助。

    【讨论】:

    【解决方案2】:

    目前我知道的唯一解决方案是手动将该手势添加到生成的测试代码中。

    onView(withId(R.id.xyz)).perform(swipeLeft());
    

    【讨论】:

    • 是的,我希望新的浓缩咖啡机能把它抽象出来,但似乎没有。
    【解决方案3】:
    Recycler view particular item swap
    
        ViewInteraction recyclerView = onView(allOf(withId(R.id.rc_vehicle_list),
                    withParent(withId(R.id.ll_vehicle)),
                    isDisplayed()));
            recyclerView.perform(actionOnItemAtPosition(3,swipeUp()));
    
    
    
    
     public static ViewAction swipeUp() {
            return new GeneralSwipeAction(Swipe.FAST, GeneralLocation.CENTER_LEFT,
                    GeneralLocation.CENTER_RIGHT, Press.FINGER);
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-02
      • 2016-09-15
      • 1970-01-01
      相关资源
      最近更新 更多