Xcode 使用Instrument(1)

UIAutomation自动化测试框架教程
本文介绍了如何使用UIAutomation框架进行iOS设备或模拟器上的自动化测试,包括准备工作、使用JavaScript导入测试脚本、配置测试环境及执行测试脚本等步骤。

UIAutomation

UIAutomation是随iOS4.0系统一起发布的一款旨在iPhone Device/Simulator上可执行的自动化测试框架。

使用UIAutomation准备

  • 被测试app源代码
  • 了解JavaScript

开始使用

  • 测试脚本的导入
    1. 使用Xcode打开被测试app工程
    2. command + i 打开Instrument
    3. 选择Automation template ->profile
      141247390123688.jpg
    4. command + R 停止 profile
    5. 找到scripts 选择 add->import...
      141249564657730.jpg
    6. 选择写好的测试脚本后会看到脚本list
      141310448097586.jpg
    7. 在脚本list右边script可以看到脚本内容
      141311547629548.png
    8. command + R执行脚本
      141312521991135.png
    9. 可以看到脚本测试log

    附上一个显示遍历UI元素树的脚本,保存为本地的showUIAElementTree.js

    DEMO_DELAY=2;
    var target = UIATarget.localTarget();
    var app = target.frontMostApp();
    
    //test functions
    
    function showCurrentViewInfo(){
        UIALogger.logStart("show CurrentViewInfoTree");
            try{
                //show the target logElementTree
                target.logElementTree();
                UIALogger.logPass();
            } catch(error){
                UIALogger.logFail(error);
            }
        }
    
    //calling test functions
    showCurrentViewInfo();

转载于:https://www.cnblogs.com/caker/p/3970939.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值