zoukankan      html  css  js  c++  java
  • monkey自定义脚本

    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)
      #等待6s
      UserWait(6000)
      #点击跳过
      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键跳转到输入框,DispathPress(keybode),传入参数为android的keybode,通过查询得知Tab键的keybode为61
      DispatchPress(61)
      UserWait(2000)
      #输入密码
      DispatchString(xw19921003)
      UserWait(2000)
      #点击登陆
      Tap(280,525,1000)

  • 相关阅读:
    告别单身淘宝小店
    微信机器人 细腻化
    # 导入模块 from wxpy import * # 初始化机器人,扫码登陆 bot = Bot()
    减小文件大小 减少 帧
    无有效图视频
    生成一张白色图片的算法--逻辑
    加logo
    字幕 3系数
    音频分析 字幕同步
    尊重百度的api语音合成规则
  • 原文地址:https://www.cnblogs.com/xwxxh/p/12981077.html
Copyright © 2011-2022 走看看