如何在AWS Device Farm中获取屏幕截图以进行android espresso测试 [英] How to take screenshot in aws device farm for android espresso testing

查看:128
本文介绍了如何在AWS Device Farm中获取屏幕截图以进行android espresso测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用aws设备场来运行我的android测试,并且我们正在使用espresso框架.今天有些测试失败,如果测试失败,我想截取屏幕截图.我已经阅读了您的文档,但找不到任何具体的内容.这是我到目前为止所知道的:

I am using aws device farm for running my android tests, and we are using espresso framework. Some of the tests are failing today, and I want to take screenshots if my test fails. I have gone through your documentation but couldn't find anything concrete. This is what I know so far:

您可以将屏幕截图作为Android UI Automator测试的一部分.

You can take screenshots as part of your Android UI Automator tests.

要获取屏幕截图,请调用takeScreenshot方法(例如,takeScreenshot("/sdcard/uiautomator-screenshots/home-screen-1234.png");).

To take a screenshot, call the takeScreenshot method (for example, takeScreenshot("/sdcard/uiautomator-screenshots/home-screen-1234.png");).

注意:所有屏幕截图都必须存储在/sdcard/uiautomator-screenshots directory中.您必须指定要存储的屏幕快照的完整路径(包括文件名). takeScreenshot方法仅适用于API级别17和更高级别.对于API级别16,支持UI Automator,但不支持屏幕截图.

Note: All screenshots must be stored in the /sdcard/uiautomator-screenshots directory. You must specify the full path (including the file name) of the screenshot to be stored. The takeScreenshot method works for API Levels 17 and higher only. For API Level 16, UI Automator is supported, but screenshots are not supported.

有什么方法可以配置aws device服务器场以自动拍摄屏幕截图,而无需调用测试中的功能?支持吗?另外,我找不到与

Is there any way I can configure aws device farm to take screenshots automatically without calling the function in test? Is it supported? Also, I couldn't find any screenshot related commands. I will really appreciate if someone could explain the steps required to screenshot. Thank you

推荐答案

免责声明:我是在AWS Device Farm上工作的开发人员.

Disclaimer: I am a developer working on AWS Device Farm.

有关takeScreenshot方法的文档是针对 uiautomator 1.0 的,而不是 uiautomator 2.0 ,它与Android Instrumentation/Espresso结合使用.

That bit of documentation about the takeScreenshot method is for uiautomator 1.0, not uiautomator 2.0 which works in conjunction with Android Instrumentation/Espresso.

我不认为Espresso添加了用于捕获屏幕截图的内置功能.但是,如果您查看官方的适用于Android的AWS Device Farm示例应用程序,则有一个帮助器类

I don't believe Espresso has added built-in functionality for capturing screenshots. However, if you take a look at the official AWS Device Farm Sample App for Android, there is a helper class ScreenShot.java that you should be able to use directly from your Espresso tests.

希望有帮助!

最佳,
安德鲁@ AWS Device Farm

Best,
Andrew @ AWS Device Farm

这篇关于如何在AWS Device Farm中获取屏幕截图以进行android espresso测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆