无法在 Firebase 测试实验室中找到用于检测 Espresso 脚本中不同设备的相机按钮为 运行 的解决方案

Not able to find solution for detecting camera button for different devices in Espresso script to be run on Firebase Test Lab

我必须使用 Espresso 创建脚本以在 Firebase 测试实验室中测试我的应用程序。我的应用程序使用相机来捕捉图像,我已经打开了默认的相机应用程序。

为了在我的设备上进行测试,我给出了我正在使用的测试设备的包名。问题是不同 Android 设备的相机应用程序包名称不同,我们不知道每个。硬编码包名也不好。

我已经搜索过了,但找不到找到解决方案的方法。

提前致谢。

我认为对于实际的相机应用程序没有好的方法,因为相机应用程序通常在设备型号和 Android 版本之间有所不同。

如何在测试中伪造这种依赖性?通过抽象化调用相机应用程序的代码,或者通过添加您自己的将被调用的假相机 activity 并且 returns 您可以按照预期的方式拍摄照片。

您可以使用 android.support.test.espresso.intent 模拟相机启动意图

https://guides.codepath.com/android/UI-Testing-with-Espresso#stubbing-out-the-camera

另请参考: http://www.qaautomated.com/2016/02/testing-camera-activity-using-intent.html

检查google样本 https://github.com/googlesamples/android-testing/tree/master/ui/espresso/IntentsAdvancedSample