学历代表过去、能力代表现在、学习力代表未来!
install_apk.py【转发】
上一篇 /
下一篇 2016-07-06 10:48:09
/ 个人分类:软件编程相关
# encoding=utf-8
# Filename:install_apk.py
#导入此程序所需要的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:\code\python\[xx.apk]')
MonkeyRunner.sleep(10)
print ('Install success')
#启动一个Activity
device.startActivity(component='[com.sohu.newslient/com.sohu.newsclient.app.SplashActivity]')
#等待10秒
MonkeyRunner.sleep(10)
print ('Starting success')
#手机端运行应用的截屏
result1=device.takeSnapshot()
#保存截图的路径
result1.writeToFile('d:\\code\\python\\3\shot.png','png')
print ('Sreenshot success')
MonkeyRunner.sleep(10)
#卸载
device.removePackage('[com.sohu.newsclient]')
print ('Uninstall success')
收藏
举报
TAG: