Robotium截图设置
2015-01-29 11:03
357 查看
Robotium截图设置
1、前提条件在被测试的应用中添加对SD卡的读写权限,文件为AndroidManifest.xml,添加以下标示
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" ></uses-permission>
2、使用solo的takeScreenshot方法来截取当前页面
takeScreenshot
public void takeScreenshot()
Takes a screenshot and saves it in "/sdcard/Robotium-Screenshots/". Requires write permission (android.permission.WRITE_EXTERNAL_STORAGE) in AndroidManifest.xml of the application under
test.
使用该方法时,如果文件目录不存在,则会自动创建,且生成的图片文件格式如下
271113-054228.jpg, 其中27为日,11为月,13为年,其他的为时分秒,且文件默认格式为jpg
代码实现为:
solo.sleep(10000) ;
solo.takeScreenshot() ;
solo.sleep(1000) ;
takeScreenshot
public void takeScreenshot(String name)
Takes a screenshot and saves it with the specified name in "/sdcard/Robotium-Screenshots/". Requires write permission (android.permission.WRITE_EXTERNAL_STORAGE) in AndroidManifest.xml
of the application under test.
Parameters:
name- the name to give the screenshot
使用该方法时,可以自定义生成的文件名字,且可以自动创建文件目录
代码实现为:
solo.sleep(10000) ;
solo.takeScreenshot("test") ;
solo.sleep(1000) ;
生成的文件为test.jpg
takeScreenshot
public void takeScreenshot(String name, int quality)
Takes a screenshot and saves the image with the specified name in "/sdcard/Robotium-Screenshots/". Requires write permission (android.permission.WRITE_EXTERNAL_STORAGE) in AndroidManifest.xml
of the application under test.
Parameters:
name- the name to give the screenshot
quality- the compression rate. From 0 (compress for lowest size)
to 100 (compress for maximum quality)
使用该方法可以对生成的图片进行压缩,大小从0到100,值越小越失真
代码实现:
solo.sleep(10000) ;
solo.takeScreenshot("test100",100) ;
solo.sleep(1000) ;
相关文章推荐
- robotium截图路径设置
- robotium的截图代码
- tomato(番茄)固件的简单设置截图
- ubuntu12.04下设置类似QQ的截图功能
- AutoIT:界面与自动化操作结合来简化日常劳动: .Net Reactor验证License,设置License,创建License,截图AutoIt自动化实现。(三)
- AutoIT:界面与自动化操作结合来简化日常劳动: .Net Reactor验证License,设置License,创建License,截图AutoIt自动化实现。(七)
- AutoIT:界面与自动化操作结合来简化日常劳动: .Net Reactor验证License,设置License,创建License,截图AutoIt自动化实现。(四)
- JDK系统环境设置【详细步骤截图】
- 截图设置弹出暂停界面
- AutoIT:界面与自动化操作结合来简化日常劳动: .Net Reactor验证License,设置License,创建License,截图AutoIt自动化实现。(二)
- dd-wrt设置说明截图
- 如何使IIS服务器支持.apk文件下载 - 步骤截图 - MIME类型设置
- Ubuntu下设置快捷截图方式
- c:\windows\temp目录权限设置 (附:截图)
- ubuntu 12.10 截图设置
- File System Auditor 设置截图
- C#制作QQ截图的自动框选功能的个人思路(二)<设置Hook>
- 设置WIN 7 截图工具的快捷方式
- win7系统自带截图工具快捷键是什么?怎么设置快捷键
- 操作 AutoIT:界面与自动化操作结合来简化日常劳动: .Net Reactor验证License,设置License,创建License,截图AutoIt自动化实现。(六)