引入头文件
fromcom.android.monkeyrunnerimportMonkeyRunner, MonkeyDevice, MonkeyImage, MonkeyView
连接设备
device_name ='192.168.58.101:5555'
device = MonkeyRunner.waitForConnection(0.5, device_name)
常用的几个事件
1 press
device.press('KEYCODE_BACK', MonkeyDevice.DOWN_AND_UP)
2 touch
device.touch((858+1082) /2, (1336+1504) /2,"DOWN_AND_UP")
3 sleep
MonkeyRunner.sleep(0.5)
4 启动Activity
device.startActivity('com.genertech.atlb/com.gener_tech.tlb.LoginActivity')
5 截屏保存
image = device.takeSnapshot()
image.writeToFile(path+imageName+"."+type, type)
下一节结合android做一个简单的登陆的自动化测试