回到地图意图espresso - UI测试的活动

问题描述 投票:1回答:1

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

android google-maps android-intent ui-automation android-espresso
1个回答
0
投票

试试这个:

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)so存储你的意图,测试不会离开你的应用程序。

© www.soinside.com 2019 - 2024. All rights reserved.