首页 > 其他 > 详细

monkey自定义脚本

时间:2020-05-28 15:50:04      阅读:37      评论:0      收藏:0      [点我收藏+]

1、启动Activity

  LaunchActivity(包名,Activity名),通过adb shell dumpsys window | findstr mCurrentFocus 来获取包名和Activity

2、点击 Tap

  Tap(x,y,time)  x坐标和y坐标,time为点击时间,单位ms

3、休眠 UserWait

  UserWait(time)  time单位ms

4、按键 DispatchPress

  DispatchPress(keyCode)  

  示例:DispatchPress(61)  则是点击Tab键  Tab键的keycode为61

5、旋转屏幕 RotateScreen

  RotateScreen(degree,persist)

  degree:角度,1代表90度

  persist:旋转后是否固定,0表示旋转后恢复原状,非0表示旋转后固定不变

6、输入字符串 DispatchString

  DispatchString(input)  括号内直接填输入内容即可

7、打开或关闭软键盘 DispatchFlip

  DispatchFlip(true/false) 

8、模拟长按事件 PressAndHold

  PressAndHold(x,y,time)  time单位ms

9、拖拽 Drag

  Drag(start_x,start_y,end_x,end_y,stepCount)

10、缩放手势 PinchZoom

  PinchZoom(x1Start, y1Start, x1End, y1End, x2Start, y2Start, x2End, y2End, stepCount)

11、长按2s

  LongPress()

12、唤醒屏幕

  DeviceWakeUp()

13、模拟电池电量信息

  PowerLog(power_log_type, test_case_status)

14、将电池信息写入sd卡

  WriteLog()

15、运行shell命令

  RunCmd(cmd)

16、向指定位置,发送单个手势

  DispatchPointer(downtime,eventTime,action,x,yxpressure,size,metastate,xPrecision,yPrecision,device,edgeFlags)

17、发送按键消息

  DispatchPointer(downtime,eventTime,action,x,yxpressure,size,metastate,xPrecision,yPrecision,device,edgeFilags)

18、运行一个instrumentation测试用例

  LaunchInstrumentation(test_name,runner_name)

20、模拟发送轨迹球事件

  DispatchTrackball

21、等待5秒

  ProfileWait

22、获取帧率

  StartCaptureFramerate()

23、 结束获取帧率

EndCaptureFramerate(input)

 

24、脚本格式

  #头文件信息

  type = raw events  #等号两边均有空格

  count = 1      #脚本执行次数

  speed = 1.0     #脚本执行速率

  start data >>    #monkey命令

  具体的脚本内容

25、案例  登陆考研帮

  type = raw events
  count = 1
  speed = 1.0
  start data >>
  #启动
  LaunchActivity(com.tal.kaoyan, com.tal.kaoyan.ui.activity.SplashActivity)
  #等待2s
  UserWait(4000)
  #点击跳过
  Tap(528,28,1000)
  UserWait(4000)
  #点击我
  Tap(520,991,1000)
  UserWait(2000)
  #点击未登录
  Tap(500,130,1000)
  UserWait(2000)
  #点击密码登陆
  Tap(285,587,1000)
  UserWait(2000)
  #点击手机号输入框
  Tap(175,335,1000)
  UserWait(2000)
  #输入账号
  DispatchString(13802562587)
  UserWait(2000)
  #tab键跳转到输入框
  DispatchPress(61)
  UserWait(2000)
  #输入密码
  DispatchString(xw19921003)
  UserWait(2000)
  #点击登陆
  Tap(280,525,1000)

monkey自定义脚本

原文:https://www.cnblogs.com/xwxxh/p/12981077.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!