美文网首页
Python搭配MonkeyRunner简单实现App自动化测试

Python搭配MonkeyRunner简单实现App自动化测试

作者: 巴鶴 | 来源:发表于2017-07-17 16:21 被阅读0次

#coding=utf-8

#导入程序所需的MonkeyRunner模块

from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice,MonkeyImage

#连接当前设备,返回一个monkeydevice

device = MonkeyRunner.waitForConnection()

if not device:

print('please connect a device to start')

else:

print('start')

#安装 安装路径

device.installPackage('d:\QiXinBao_Market_AnZhi.apk')

MonkeyRunner.sleep(12)

print('install success')

#启动一个Activity

device.startActivity(component='com.bertadata.qxb/com.bertadata.qxb.activity.SplashActivity')

#启动一个Activity 变量方法二

#package = 'com.bertadata.qxb'

#activity = '.activity.SplashActivity'

#component = package+'/'+activity

#device.startActivity(component)

#等待15秒

MonkeyRunner.sleep(15)

print('starting success')

#手机端运行程序的截屏

result1 = device.takeSnapshot()

#保存截图的路径

result1.writeToFile('d:\\picture\\test1.png','png')

print('Screenshot success')

MonkeyRunner.sleep(15)

#卸载

device.removePackage('com.bertadata.qxb')

print('uninstall success')

MonkeyRunner.sleep(8)

相关文章

网友评论

      本文标题:Python搭配MonkeyRunner简单实现App自动化测试

      本文链接:https://www.haomeiwen.com/subject/dkqqkxtx.html