app自动化测试如何,自动识别版本号与型号
adb命令
获取系统版本:adb shell getprop ro.build.version.release
获取手机型号:adb shell getprop ro.product.model
#使用os库中的os.popen的方法,需要使用.read的方法读取出来
使用os的库
import os
data = os.popen("adb shell getprop ro.build.version.release")
print(data)
#输出结果为:
<os._wrap_close object at 0x0000021E0527DA88>
#使用read()的方法
print(data.read())
输出结果为:5.1.1
此时的值为5.1.1,此时的版本号已经展示出来,但是当你传进"app自动化的配置参数"中会展示
{'platformName': 'Android', 'platformVersion': '5.1.1\n\n', 'deviceName': '2232323', 'noReset': True, 'appPackage': 'com.xxzb.fenwoo', 'appActivity': 'com.xxzb.fenwoo.activity.addition.WelcomeActivity'}
当中的platformVersion为5.1.1\n\n
需要使用rstrip("\n"),去除\n\n
print(data.read().rstrip("\n"))
输出结果为:5.1.1
截图:
获取手机型号与以上步骤即可,传入对应的配置参数完成自动识别版本号与型号。