日常总结

通过AppiumUI自动化收集iOS-App性能数据的方法:

1.自定义Instruments 模板
通过自定义 Instruments 模板可以实现在执行自动化操作的同时记录性能数据。模板需包含如下 instrument:
UI Automation
Activity Monitor
Core Animation

2.Appium 参数配置

2.1配置 iOS Settings > Advanced > Trace Template Path 指向上述模板,让 Appium 使用该模板启动 Instruments

2.2 或者Appium命令行参数里增加tracetemplate模板
Appium –tracetemplate AUTOMATIONTRACETEMPLATEPATH
(IOS-only) .tracetemplate file to use with Instruments

3.执行测试case
Appium测试脚本跑完后,Instruments 生成的 Trace 数据默认保存在 /tmp/appium-instruments 下面

4.解析结果
用./InstrumentsParser解析instrumentscli0.trace文件成.json文件
$ ./InstrumentsParser -p DPScope -i /tmp/appium-instruments/instrumentscli0.trace

5.结果展示
1.json2csv
2.处理数据,使用 Highcharts 图表库 进行展示

if __name__ == '__main__':
    trace_template = os.path.join(os.path.dirname(__file__), "perf-report/NovaPerfDevice.tracetemplate")
    trace_template = os.path.abspath(trace_template)
    appiumServer = subprocess.Popen("appium --no-reset --log-level error:error --tracetemplate " + trace_template, shell=True)
    #appiumServer = subprocess.Popen("appium --no-reset --tracetemplate " + trace_template, shell=True)
    time.sleep(5)

    suite = unittest.TestLoader().loadTestsFromTestCase(PerformanceCollectionTest)
    result = unittest.TextTestRunner(verbosity=2).run(suite)
    time.sleep(2)

    print('Generating report...')
    subprocess.Popen("sh generate-ios-perf-report.sh", shell=True)
    time.sleep(5)

    os.system("ps -ef | grep appium |"
          " awk '{print $2}' |xargs  kill {} 2>/dev/null")

    if not result.wasSuccessful():
        exit(1)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值