五、Appium-python-UI自动化之自动获取devicesd,version,package,appActivity
from appium import webdriver # 使用正则表达式筛选设备 id import re # 使用time.sleep(xx)函数进行等待 import time # 使用 os 模块调用命令 import os def get_sales_package(): # 测试的销售APP包的路径和包名 sales_appLocation = os.path.split(os.path.dirname(__file__))[0] + "/app_package/sales_app_product.apk" return sales_appLocation def get_dragon_package(): # 测试的客户APP包的路径和包名 dragon_appLocation = os.path.split(os.path.dirname(__file__))[0] + "/app_package/dragon_app_product.apk" return dragon_appLocation def get_app_devices_id(): # 读取设备 id readDeviceId = list(os.popen(‘adb devices‘).readlines()) # 正则表达式匹配出 id 信息 deviceId = re.findall(r‘^\w*\b‘, readDeviceId[1])[0] return deviceId def get_app_device_version(): # 读取设备系统版本号 deviceAndroidVersion = list(os.popen(‘adb shell getprop ro.build.version.release‘).readlines()) deviceVersion = re.findall(r‘^\w*\b‘, deviceAndroidVersion[0])[0] return deviceVersion def get_app_app_package_info(app): if app == "sales": app_location = get_sales_package() elif app == "dragon": app_location = get_dragon_package() # 读取 APK 的 package 信息 appPackageAdb = list(os.popen(‘aapt dump badging ‘ + app_location).readlines()) for i in range(len(appPackageAdb)): # print(str(i)+":"+str(appPackageAdb[i])) if "package" in appPackageAdb[i]: appPackage = re.findall(r‘\‘com\w*.*?\‘‘, appPackageAdb[i])[0] return appPackage def get_app_app_activity_info(app): if app == "sales": app_location = get_sales_package() app_location = get_sales_package() # 读取 APK 的 package 信息 appPackageAdb = list(os.popen(‘aapt dump badging ‘ + app_location).readlines()) for i in range(len(appPackageAdb)): # print(str(i)+":"+str(appPackageAdb[i])) if "launchable-activity" in appPackageAdb[i]: appActivity = re.findall(r‘\‘com\w*.*?\‘‘, appPackageAdb[i])[0] return appActivity
相关推荐
liuxudong00 2020-11-19
wwzaqw 2020-11-11
lihaoxiang 2020-11-05
CrossingX 2020-11-04
xuegangic 2020-10-17
86417413 2020-11-25
83206733 2020-11-19
86276537 2020-11-19
83266337 2020-11-19
86256434 2020-11-17
zhouboxiao 2020-11-16
rise 2020-11-22
sssdssxss 2020-11-20
windle 2020-11-10
孙雪峰 2020-10-30
85477104 2020-11-17
xfcyhades 2020-11-20
cheidou 2020-11-19