关于ios使用Automation自动测试
来源:互联网 发布:windows elf 编辑:程序博客网 时间:2024/05/17 02:25
最近看了一篇英文文章觉得写的非常好,所以根据本人所学总结过来,不过英文水平有限,只能半猜半测试的弄过来,先说明本人主攻技术,所以英文如果翻译有错,请多担待。
自动测试可以测试性能等,学习之前,先讲讲需要用到的工具:xcode需要4.0以上,不过4.5以上commond-line可以截图和使用脚本。
从xcode4.0以后就增加了一个UIAutomation框架,既可以用在模拟器也能用在真机上。有文档可以参看参考资料。
首先,如果不想自己写例子就下载一个参考资料1中的例子吧,先在模拟器上使用吧。使用Product > Profile命令启动,可看到instruments启动了,这时选择profile,
这个时候可以写script了,也可以import一个js文件,这两种都可以通过左侧的scripts里面的add按钮进行操作:
这里就懒得create了,直接import一个例子中写好的js文件吧。
将右侧的显示区设置为script区:
可以看到里面的内容变成了:
var testName = "Test 1";
var target = UIATarget.localTarget();
var app = target.frontMostApp();
var window = app.mainWindow();
//--
UIALogger.logStart( testName );
app.logElementTree();
//-- select the elements
UIALogger.logMessage( "Select the first tab" );
var tabBar = app.tabBar();
var selectedTabName = tabBar.selectedButton().name();
if (selectedTabName != "First") {
tabBar.buttons()["First"].tap();
}
//-- tap on the text fiels
UIALogger.logMessage( "Tap on the text field now" );
var recipeName = "Unusually Long Name for a Recipe";
window.textFields()[0].setValue(recipeName);
target.delay( 2 );
//-- tap on the text fiels
UIALogger.logMessage( "Dismiss the keyboard" );
app.logElementTree();
app.keyboard().buttons()["Return"].tap();
var textValue = window.staticTexts()["RecipeName"].value();
UIALogger.logMessage( "text value=" + textValue );
if (textValue === recipeName){
UIALogger.logPass( testName );
}
else{
UIALogger.logFail( testName );
}
点击红色按钮运行一下吧,可以看到一系列的动作出现了,都是自动的哦。下面就来进行详细的分析一下吧。不过今天不太想写了,所以还是明天来吧。这些代码很简单,一看基本就明白了。不过明天还是会进行详细解说的。
参考资料:
1、iOS Automated Tests with UIAutomation
2、UI Automation JavaScript Reference
3、About Instruments
4、wwdc
- 关于ios使用Automation自动测试
- Automation自动化测试IOS设备
- 使用UIAutomation测试iOS App(Test iOS Apps with UI Automation) - 翻译前言
- IOS 自动化 2-UI Automation-功能测试
- iOS Automation关于Alert的处理
- iOS Automation关于Alert的处理
- 使用UI Automation实现自动化测试 -1
- 使用UI Automation实现自动化测试 -2
- 使用UI Automation实现自动化测试 -3
- 使用UI Automation实现自动化测试 -4.1
- 使用 UI Automation 实现自动化测试--1
- 使用 UI Automation 实现自动化测试--2
- 使用 UI Automation 实现自动化测试--3
- 使用 UI Automation 实现自动化测试--4.1
- 使用 UI Automation 实现自动化测试--4.2
- 使用 UI Automation 实现自动化测试--4.3
- 使用 UI Automation 实现自动化测试--4.4
- 使用 UI Automation 实现自动化测试--4.5
- 64位SecureFx crack 速成
- 元数据的类别
- 开启Mysql慢查询
- iOS5 NSAttributedString
- sq更新语句条件子查询中有分组统计的sql,导致错误1093
- 关于ios使用Automation自动测试
- 字符串系列之最长回文子串
- oracle学习笔记
- Windows下使用Sublime Text 2调试/运行 C/C++ 程序
- 1)第一个c++程序;
- 23种设计模式总集-个人培训记
- ORACLE中NOT IN 的替代
- Nfs服务器简单搭建
- 解决gdal集成libkml的链接错误