monkey测试===monkeyrunner测试教程(2)
我先引入一段代码:
#test.py
from com.android.monkeyrunner import MonkeyRunner as mr device=mr.waitForConnection(1.0,'ZTEC880U') #step1 device.startActivity(component="com.sinosun.tchats/.WiWelcomeActivity") #step2 mr.sleep(2) #step3 result=device.takeSnapshot() #step4 result.writeToFile('F:\\monkeyrunner\\recoder\\test.png','png')
总共做了四件事:
step1:连接设备和monkeyrunner
step2:打开程序“T信”
step3:sleep2秒
step4:截图,并以test.png保存在目录F:\\monkeyrunner\\recoder\\
运行结果:
我的脚本是在F盘存放,所以运行脚本的命令>>>monkeyrunner F:\test.py
生成的截图:
纸上得来终觉浅,绝知此事要躬行!