利用eclipse或者pycharm编写monkeyrunner脚本,cmd打开应用“转转”并截图保存到D盘
1、eclipse或者pycharm编写monkeyrunner脚本:
from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice,MonkeyImage device=MonkeyRunner.waitForConnection() package ='com.wuba.zhuanzhuan' activity = '.presentation.view.activity.LaunchActivity' component = package +'/'+ activity device.startActivity(component) MonkeyRunner.sleep(2) result = device.takeSnapshot() result.writeToFile('D:\TEST.png','png')
pycharm:
eclipse:
两个都会报错,但是不管啦。
个人比较喜欢pycharm,比较人性化,右击左侧的文件test.py,会有file path,文件的保存路径。
2、查看保存路径:
E:\pycharm\run\test.py
E:\java\workspace\TestPython\a\Test.py
3、手机连接电脑。打开USB调试。电脑打开cmd,
分别输入:
monkeyrunner E:\pycharm\run\test.py 和 monkeyrunner E:\java\workspace\TestPython\a\Test.py
4、等待,果真,手机打开了应用“转转”,并且截取图片保存到了D盘