Automating User Interface Testing with Instrument-利用Automation进行自动化测试
2016-05-04 15:31
507 查看
一、需求场景
当我们做好一款app的时候,需要对其进行多次重复的功能测试时很有必要的。目前我做的项目AnyWhere就需要这么一个场景,需要不停的对其进行live和stop,检测crash的log.原文地址http://blog.csdn.net/Smiling8866/article/details/51315358
二、解决方法
1、对于测试人员:可以利用Appium,编写脚本进行自动化测试。当然还有其它的工具。这种测试不需要提供源码。
2.对于开发人员:
可以利用Instruments中的Automation框架进行自动化测试,只不过在测试之前需要对源码进行一次profile.
苹果官方提供的有这方面的文档,可以去官网查阅。不过,其给的文档看着有点怪怪的,所以我在下面把它的教程文档给翻译了一下。
原文地址http://blog.csdn.net/Smiling8866/article/details/51315358
三、对Automating User Interface Testing with Instrument 的翻译
1.什么是UI的自动化Automates UIKit based applications(界面的自动化依赖于app)
Touch based(给予触摸的)
IPhone,iPod touch band IPhone Simulator(支持IPhone,iPod,IPhone模拟器)
Integrate in Instruments(在Instruments中被整合)
Accessibility based (依赖于可接触性)
JavaScript automation scripts (脚本是用js写的)
2.对Elements的介绍
UIAElement——基类元素
Name
Value
Elements
Parent
……没耐心了,不想翻译了。。。
原文地址http://blog.csdn.net/Smiling8866/article/details/51315358
四、我的脚本
原文地址http://blog.csdn.net/Smiling8866/article/details/51315358var target = UIATarget.localTarget(); var app = target.frontMostApp(); var window = app.mainWindow(); var i = 0; var totalTimes = 100; // 测试总次数 target.setDeviceOrientation(UIA_DEVICE_ORIENTATION_PORTRAIT); while(true){ UIALogger.logStart("AnyWherePro Automatic Test"); i++ target.delay(10); // 留10秒的时间刷新RList window.staticTexts()[9].tapWithOptions({tapOffset:{x:0.38,y:0.46}}); // 点击RList列表 target.delay(2); // 2秒钟展示RList的内容 window.tableViews()[1].tapWithOptions({tapOffset:{x:0.38,y:0.08}}); // 选择R target.delay(2); // 2秒钟展示选中的R的内容 target.tap({x:132.00,y:298.50}); // 点击屏幕,让RList折叠起来 window.buttons()["begin livingimage"].tap(); // 开始live var liveButton = window.buttons().withName("stop livingimage"); var screenImage_live = "screenshot_live"; var screenImage_stop = "screenshot_stop"; if(liveButton.isValid()){ UIALogger.logMessage("log info-------"+i+" time--------->start live success.."); target.captureScreenWithName(screenImage_live+i); }else{ UIALogger.logMessage("log info-------"+i+" time--------->start live failed.."); } target.setTimeout(30); target.delay(30); // live 30秒 window.buttons()["stop livingimage"].tap(); // 停止live liveButton = window.buttons().withName("begin livingimage"); if(liveButton.isValid()){ UIALogger.logMessage("log info-------"+i+" time--------->stop live success.."); target.captureScreenWithName(screenImage_stop+i); }else{ UIALogger.logMessage("log info-------"+i+" time--------->stop live failed.."); } if(i == totalTimes){ break; } UIALogger.logPass("AnyWherePro Automatic Test"); } 原文地址http://blog.csdn.net/Smiling8866/article/details/51315358
注意:一定要打开手机开发者选项中的允许自动化设置权限
相关文章推荐
- 设计模式之适配器模式
- 在SpringMVC中使用@RequestBody注解处理json时,报出HTTP Status 415的解决方案
- 强制关闭iPhone iPad AppleWatch MacOS
- 程序在运行过程中内存的分配问题
- linux shell 多个命令一起执行的几种方法
- Linear Classification: Support Vector Machine, Softmax
- Runtime 动态添加属性
- c++ getline(),get()函数笔记
- 字符串中去掉空格
- javascript继承
- [置顶] Android pdf解析方案
- java工程师成神之路-基础篇
- 常见电脑显示器分辨率及其比例
- 如何让Mac应用程序重置
- Debian Live 项目的剧变
- hibernate中的核心类和接口细节总结
- sql解释执行顺序
- spring加载bean实例化顺序
- 你的代码有重复吗?
- Java 记录java基本类型与Byte数组之间相互转换