monkeyrunner脚本编写

来源:互联网 发布:爱卓金蝶erp软件 编辑:程序博客网 时间:2024/05/17 07:54
直接贴源码吧,主要就是进入APP内的消息发送页面,然后编写文本点击发送。
再通过monkeyrunner test.py执行,test.py即为编写的脚本。
#!/usr/bin/env python#coding:utf-8from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice,MonkeyImage#连接设备device=MonkeyRunner.waitForConnection(3,"850ABM5SRXVQ")#启动APPdevice.startActivity("com.wuba/com.wuba.home.activity.HomeActivity")MonkeyRunner.sleep(2)#点击消息中心device.touch(850,1850,"DOWN_AND_UP")MonkeyRunner.sleep(3)#点击回话device.touch(500,800,"DOWN_AND_UP")MonkeyRunner.sleep(2)#点击输入框device.touch(500,1850,"DOWN_AND_UP")MonkeyRunner.sleep(3)#输入某词testdevice.type("test")MonkeyRunner.sleep(2)#点击回车device.press('KEYCODE_ENTER','DOWN_AND_UP')MonkeyRunner.sleep(2)#点击发送device.touch(1000,1150,"DOWN_AND_UP")MonkeyRunner.sleep(1)#截图image = device.takeSnapshot()image.writeToFile("./test.png","png")
0 0