# encoding=utf-8
# Filename:install_apk.py
#導入此程序所須要的monkeyrunner模塊
#from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice,MonkeyImagepython
#連接當前設備,返回一個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')android
#手機端運行應用的截屏
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')app