UIAutomation
UIAutomation是随iOS4.0系统一起发布的一款旨在iPhone Device/Simulator上可执行的自动化测试框架。
使用UIAutomation准备
- 被测试app源代码
- 了解JavaScript
开始使用
- 测试脚本的导入
- 使用Xcode打开被测试app工程
- command + i 打开Instrument
- 选择Automation template ->profile
- command + R 停止 profile
- 找到scripts 选择 add->import...
- 选择写好的测试脚本后会看到脚本list
- 在脚本list右边script可以看到脚本内容
- command + R执行脚本
- 可以看到脚本测试log
附上一个显示遍历UI元素树的脚本,保存为本地的showUIAElementTree.js
DEMO_DELAY=2;var target = UIATarget.localTarget();var app = target.frontMostApp();//test functionsfunction showCurrentViewInfo(){ UIALogger.logStart("show CurrentViewInfoTree"); try{ //show the target logElementTree target.logElementTree(); UIALogger.logPass(); } catch(error){ UIALogger.logFail(error); } }//calling test functionsshowCurrentViewInfo();