【问题标题】:Come back to activity from maps intent espresso - UI testing从 Maps Intent espresso 回到活动 - UI 测试
【发布时间】:2018-01-26 23:32:12
【问题描述】:

我正在使用 Espresso 进行 UI 测试。我想测试一个功能,将应用程序意图应用到谷歌地图应用程序并返回相同的活动。意图已成功完成,谷歌地图已打开,但我无法控制地图应用程序,Espresso.pressBack(); 无法正常工作。有没有办法使用 espresso 按下返回按钮?

【问题讨论】:

    标签: android google-maps android-intent ui-automation android-espresso


    【解决方案1】:

    试试这个:

    androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
    

    然后

    UiDevice mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
    mDevice.pressBack();
    

    我在这里找到的:Espresso.pressBack() does not call onBackPressed()

    但是,对于这个用例,按回可能不是您想要的解决方法。考虑使用 Intent.intending(Matcher) 存根您的意图,以便测试不会离开您的应用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多