首页 > 学院 > 开发设计 > 正文

monkey和monkey runner学习笔记

2019-11-06 09:22:16
字体:
来源:转载
供稿:网友
1.获取APP包名:adb shell "logcat | grep START"   I是管道的意思:将上一个命令的输出作为下一个命令的输入。 grep start :抓取start标签的log 信息进行输出cmp=**/  包名2.给指定包打压力:adb shell monkey -v(把执行的事件都列出来) -p package 10003.monkey高级参数的应用--throttle 1000(间隔时间) 10(事件数)指定随机生成数的seed值  adb shell monkey -s<seed><event-count>  加入的seed值可以指定操作设定触摸事件百分比:adb shell monkey --pct-touch <percent>设定动作事件百分比:adb shell monkey --pct-motion <percent> 设定轨迹球事件百分比:adb shell monkey --pct-trackball <percent>设定基本导航事件百分比,输入设备的上,下,左,右:adb shell monkey --pct-nav <percent>设定主要导航事件百分比,兼容中间键,返回键,菜单按键 :adb shell monkey --pct-majornav <percent>设定系统导航事件百分比,HOME,BACK,拨号及音量键 :adb shell monkey --pct-syskeys<percent>设定启动activity的事件百分比:adb shell monkey --pct-appswitch <percent>设定不常用事件的百分比 : adb shell monkey --pct-anyevent<percent>忽略崩溃和异常:adb shell monkey --ignore-crashes <event-count>忽略超时事件:adb shell moneky --ignore-timeouts <event-count>4.monkey script执行monkey脚本的命令:adb shell monkey -f <scriptfile> <event-count>Dispatch Trackball命令 轨迹球事件 Dispatch Trackball(long downtime,long eventide,int action,float x,float y,float PRessure,float size,int metastate,float xprecision,float yprecision,int device,int edgeflags)  action 0代表的按下,1代表弹起,xy代表坐标点DispatchPointer命令:DispatchPointer(long downtime,long eventide,int action,float x,float y,float pressure,float size,int metastate,float xprecision,float yprecision,int device,int edgeflags)DispatchString命令:输入字符串事件 DispatchString(String text)LaunchActivity命令:LaunchActivity(package,Activity)UserWait命令:等待事件 UserWait(1000)DispatchPress命令:按下键值 DispatchPress(int keycode)#keycode 66 回车键5.MonkeyRunner APIMonkeyRunner和monkey的区别,可以在显示操作中实现截屏操作-alert 警告框:void alert(string message,string title,string okTitle)-waitForConnection :等待设备连接,有多个device id,需要指明具体哪个设备         waitForConnection(float timeout,string deviceid)-drag 拖动 drag(tuple start,tuple end,float duration,integer steps)          start 起点位置      end 终点位置    duration 手势持续的时间   steps插值点的步数,默认10 -press 按键 press(string keycode,dictionary type) keycode名,Down.UP.DOWN_AND_UP-startActivity  启动应用 startActivity(package+'/'+activity)-touch 点击  touch(integer x,integer y,integer type)-type 输入  type(string message)-takeSnapshot 截屏 MonkeyImage takeSnapshot()-sameAs   图像对比 boolean sameAs (MonkeyImage other,float percent)-writeoFile 保存图像文件 void writeToFile (string path,string format) 
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表