Appium 求助: Appium+python 采集 iOS 客户端性能数据, 无法用 instruments 打开

huhu · July 14, 2020 · Last by 少女 replied at July 15, 2020 · 1893 hits

最近尝试做最基础的客户端性能测试,
我司是使用 appium + python 做的 UI 自动化测试,
看了这个文章 ,appium 可以采集 iOS / Android 的性能数据(此文为 iOS)

https://appiumpro.com/editions/12-capturing-performance-data-for-native-ios-apps

因此我想使用 appium 将 performance 数据采集直接写在 UI 自动化框架里。

这篇文章是使用 java 存成 zip 文件, 解压就能用 instruments 打开,如下:

File traceZip = new File("/path/to/trace.zip");
String b64Zip = (String)driver.executeScript("mobile: stopPerfRecord", args);
byte[] bytesZip = Base64.getMimeDecoder().decode(b64Zip);
FileOutputStream stream = new FileOutputStream(traceZip);
stream.write(bytesZip);

At this point, we'll have a nice little trace.zip sitting at the specified location on disk. We can now simply unzip it and double-click it to open the trace file up in the Instruments viewer:

我对照着写成了 python, 也可以生成.zip 文件,但是解压缩后的文件不是 xxx.trace, 而是一个文件夹,无法用 instruments 打开

b64Zip = str(driver.execute_script('mobile: stopPerfRecord', {'profileName': 'Time Profiler'}))
bytesZip = base64.b64decode(b64Zip)

with open('trace.zip', 'wb') as fz:
    fz.write(bytesZip)

我解压后是这样的目录结构:

在网上找了很久,都没有找到相关的内容,感觉 appium 采集 performance 数据好像使用的很少
所以想问下有没有大佬遇到过这种问题,是怎么解决的呢?

最佳回复

with open('trace.trace.zip', 'wb')

共收到 3 条回复 时间 点赞

with open('trace.trace.zip', 'wb')

huhu #2 · July 15, 2020 Author
Jacc 回复

啊 可以了,谢谢大佬!
接下来要想想怎么把这些个数据解析出来做测试报告了

最近也在打算研究这 iOS 客户端性能数据采集的。期待

需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up