#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)