安卓 monkeyrunner笔记
作者:互联网
安卓下载各种tools的网站,很赞。
AndroidDevTools - Android开发工具 Android SDK下载 Android Studio下载 Gradle下载 SDK Tools下载
monkeyrunner命令语法
monkeyrunner -plugin <plugin_jar> <programe_filename> <programe_option>
# -*- coding: utf-8 -*- # @Time : 5:46 PM # @Athor : WuHe # @File : MonkeyrunnerRandompress.py from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage import random,time device = MonkeyRunner.waitForConnection() if not device: print('Please connect a device to start') else: print('start test') file_object=open(r'C:\Users\WHE9SZH\Desktop\New\test.txt','w+') num = 0 while num < 20: x = random.randint(0, 1920) y = random.randint(0, 720) device.touch(x, y, 'DOWN_AND_UP') print(x) print(y) MonkeyRunner.sleep(0.5) num+=1 file_object.write(str('value: ')+str(x)+' '+str(y)+'\n') file_object.write(str('num=')+str(num)+'\n') file_object.write(time.asctime(time.localtime(time.time()))+'\n') file_object.write('logcat -v time *:W' + '\n')#没看懂这个log什么原理,还在研究 file_object.close() print('MonkeyRunner Complete')
启动monkeyrunner recorder的py程序:
#-*- coding: utf-8 -*- #@Time : 1/29/2022 #@Athor : WuHe #@File : monkeyrecorder.py #这里的monkey_recorder.py需要拷贝到和monkeyrunner同级目录下,即sdk/tools from com.android.monkeyrunner import MonkeyRunner as mr from com.android.monkeyrunner.recorder import MonkeyRecorder as recorder device = mr.waitForConnection() recorder.start(device)
标签:monkeyrunner,安卓,object,笔记,num,file,time,device 来源: https://www.cnblogs.com/passagain/p/15853147.html