导入MonkeyRunner相关的包:
from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice
获取一个device对象:
device = MonkeyRunner.waitForConnection()
i = 1
while i > 0: //while循环的时候,循环体需要缩进一个TAB
触摸设备25px,300px的位置:
device.touch(25,300,"DOWN_AND_UP")
等待3秒:
MonkeyRunner.sleep(3)
按下HOME键:
device.press('KEYCODE_HOME','DOWN_AND_UP')