操作命令:
导包:
import sys
from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice
from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice
device=MonkeyRunner.waitForConnection()
#启动activity
device.startActivity(component="cn.trichat.angus999/.MainActivity t12135")
#增加等待时间
MonkeyRunner.sleep(10, 0) #后面的0可以不写
MonkeyRunner.sleep(10, 0) #后面的0可以不写
#点击
device.touch(325, 2134, 'DOWN')
#按下HOME键
device.press('KEYCODE_HOME',MonkeyDevice.DOWN_AND_UP)
#按下BACK键
device.press('KEYCODE_BACK',MonkeyDevice.DOWN_AND_UP)
#按下下导航键
device.press('KEYCODE_DPAD_DOWN',MonkeyDevice.DOWN_AND_UP)
#按下上导航键
device.press('KEYCODE_DPAD_UP',MonkeyDevice.DOWN_AND_UP)
#按下OK键
device.press('KEYCODE_DPAD_CENTER',MonkeyDevice.DOWN_AND_UP)
增加循环判断,简单py脚本就算完成
执行测试
将已经编写好的.py文件,直接运行
monkeyrunner +D:/文件路径/文件名.py(后面添加>D:/log.txt生成日志)