# -*- codeing = utf-8 -*-
from appium import webdriver
# 例子:使用appium对app做安装卸载测试
# 1.构造字典===》Capability===》appium服务端
desired_caps={}
desired_caps['platformName']='Android'
desired_caps['platformVersion']='11'
desired_caps['deviceName']='a17aa10f'
# 安装被测试app
# 路径前写r ===》防止路径被转义
desired_caps['app']=r'F:\luyin\NewSoundRecorder-b4ba0aa-OPPO-full-domestic-30-release.apk'
desired_caps['appPackage']='com.coloros.soundrecorder'
desired_caps['appActivity']='oppo.multimedia.soundrecorder.filebrowser.BrowseFile'
desired_caps['noReset']='false'
# 2.webdriver对象连接appium服务端使用(注意:appium服务端是打开状态) ===》webdriver
# 注意导包的路径:from appium import webdriver
# Remote(参数1:appium服务端地址,参数2:字典信息)
driver = webdriver.Remote('http://localhost:4723/wd/hub',desired_caps)
# 3.webdriver对象(属性+方法)
# a)is_app_installed 判断app是否安装方法
if driver.is_app_installed("com.coloros.soundrecorder"):
print("安装成功")
else:
print("安装失败")
# b)remove_app 卸载app的方法
driver.remove_app("com.coloros.soundrecorder")
print("自动卸载成功")
print("安装卸载一次")
appium自动化安装与卸载测试
最新推荐文章于 2024-05-22 23:45:59 发布