Appium-python-UI自动化之自动获取devicesd,version,package,appActivity
Posted csjin-study
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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*‘, 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*‘, 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‘‘comw*.*?‘‘, 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‘‘comw*.*?‘‘, appPackageAdb[i])[0] return appActivity
以上是关于Appium-python-UI自动化之自动获取devicesd,version,package,appActivity的主要内容,如果未能解决你的问题,请参考以下文章
Appium-python-UI自动化之页面-上下滑动左右滑动swipe方法操作
八Appium-python-UI自动化之记一次使用隐式等待:implicitly_wait()的坑
七Appium-python-UI自动化之强制等待:sleep,隐式等待:implicitly_wait,显示等待:WebDriverWait()
python+selenium Web自动化之获取网页元素的基本方法