您的位置:首页 > 移动开发

RF+Appium 压力测试:安装卸载和升降级测试

2017-09-15 17:19 621 查看

RF+Appium 压力测试:安装卸载和升降级测试

移动终端特性测试:安装卸载和升降级测试

这里只已安装卸载测试为例,升降级测试类似。

一、用例:安装卸载压力测试



APP 是否安装

已安装,先卸载

安装 APP,记录内存详情

Appium 登录 app, 记录内存详情

卸载 APP

自定义关键字:

Adb Install Package apk=${version}

说明:如果要升降级测试,可以指定版本。默认情况下是当前版本。

自定义关键字:Meminfo

后台调用 adb shell dumpsys meminfo 命令,实时监控手机系统资源

三、关键字:Adb Install Package apk=${version} & Adb Uninstall Package apk=${version}

源码文件:adb_shell.py

def adb_install_package(self, apk=None, package_name=None):
"""
Install packages through ADB command.
Examples:
|     Adb Install Package    | ${apk_name} | ${package_name} |
"""
if apk == None:
apk = os.getenv('G_APPIUM_APP_APK')
else:
apk = os.path.join(os.getenv('G_APPIUM_APP_DIR'), apk)

if package_name == None:
package_name = os.getenv('G_APPIUM_APP_PACKAGE')
if self.is_package_installed
c312
(package_name):
self.adb_uninstall_package(package_name)
try:
cmd = 'adb -s {} install {}'.format(os.getenv('U_APPIUM_DEVICE_NAME'), apk)
print cmd
text = os.popen(cmd)
content = text.read()
print content
if 'Success' in content:
print 'Pass: Install {} succeeded. \nVersion: {}'.format(package_name, apk)
else:
self.__raiseError('Fail: Could NOT intall {}'.format(package_name))
except Exception, e:
print str(e)

def adb_uninstall_package(self, package_name=None):
"""
Uninstall packages through ADB command.
Examples:
|    Adb Uninstall Package    | ${package_name} |
"""
if package_name == None:
package_name = os.getenv('G_APPIUM_APP_PACKAGE')
if not self.is_package_installed(package_name):
self.__raiseError('Fail: APP {} is not installed.'.format(package_name))
try:
cmd = 'adb -s {} uninstall {}'.format(os.getenv('U_APPIUM_DEVICE_NAME'), package_name)
print cmd
text = os.popen(cmd)
content = text.read()
print content
if 'Success' in content:
print 'Pass: Uninstall {} succeeded.'.format(package_name)
else:
self.__raiseError('Fail: Could NOT unintall {}'.format(package_name))
except Exception as e:
print str(e)

def is_package_installed(self, package_name):
"""
Check target package is installed through ADB command.
Examples:
| ${status} | Is Package Installed |
"""
packages = self.get_third_party_packages()
if package_name in packages:
return True
else:
return False

def get_third_party_packages(self):
"""
Get Third-party packages through ADB command.
Examples:
| ${apk_name} | Get Third Party Packages |
"""
apks = []
try:
f = os.popen('adb shell pm list package -3')
for x in f.readlines():
apks.append(x.strip().split(':')[1])
return apks
except Exception, e:
print str(e)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: