zoukankan      html  css  js  c++  java
  • Monkey写脚本

    今天学习使用monkey测试一个应用的登陆,遇到些问题记录下:

    先上代码:

    type=raw events
    count = 1
    speed = 1.0
    start data >>
    LauncheActivity(com.android.smartmirror,com.android.smartmirror.activities.MainActivity)
    UserWait(500)

    //用户名输入框
    DipatchePointer(0,0,0,271,391,0,0,0,0,0,0,0)
    DipatchePointer(0,0,1,271,391,0,0,0,0,0,0,0)
    UserWait(1500)
    DispatchString(9876543210) //用户名
    UserWait(500)

    //密码输入框
    DipatchePointer(0,0,0,242,595,0,0,0,0,0,0,0)
    DipatchePointer(0,0,1,242,595,0,0,0,0,0,0,0)
    UserWait(1500)
    DispatchString(1234567890)
    UserWait(1500)
    Tap(620,810,1500)
    UserWait(1500)

    结果运行的时候,光标在哪,就在哪连续输入9876543210、1234567890,也不换对应的输入框,很郁闷,不是道是什么原因(有哪位大神知道,请指教一下)。后来想了个办法,使用Tap,结果脚本变成下满的样子:

    type=raw events
    count = 1
    speed = 1.0
    start data >>
    LauncheActivity(com.android.smartmirror,com.android.smartmirror.activities.MainActivity)
    UserWait(500)
    //用户名输入框
    Tap(271,391,500)
    UserWait(1500)
    DipatchePointer(0,0,0,271,391,0,0,0,0,0,0,0)
    DipatchePointer(0,0,1,271,391,0,0,0,0,0,0,0)
    UserWait(1500)
    DispatchString(9876543210) //用户名
    UserWait(500)
    //密码输入框
    Tap(242,595,500)
    UserWait(1500)
    DipatchePointer(0,0,0,242,595,0,0,0,0,0,0,0)
    DipatchePointer(0,0,1,242,595,0,0,0,0,0,0,0)
    UserWait(1500)
    DispatchString(1234567890)
    UserWait(1500)
    Tap(620,810,1500)
    UserWait(1500)

    运行正常了,但貌似脚本中没必要使用DispatchPointer,就试了一下变成下面的脚本:

    type=raw events
    count = 1
    speed = 1.0
    start data >>
    LauncheActivity(com.android.smartmirror,com.android.smartmirror.activities.MainActivity)
    UserWait(500)
    Tap(271,391,500)
    UserWait(1500)
    DispatchString(9876543210)
    UserWait(500)
    Tap(242,595,500)
    UserWait(1500)
    DispatchString(1234567890)
    UserWait(1500)
    Tap(620,810,1500)
    UserWait(1500)

    结果运行也是正常的,现在更纳闷了,那DispatchPointer到底什么时候用呢?有哪位大神知道,请解下惑,不胜感激,谢谢。

  • 相关阅读:
    国标ikecin插座资料
    LED平面管测试资料
    elementui使用MessageBox 弹框自定义内容$msgbox:实现一个textarea文本输入框
    ajax请求的时候后台有三个服务器地址
    前端用xshell向后端服务器部署项目
    vue+echarts 实现map3D地图tooltip弹框读取后台返回的数据,并显示弹框
    AWS网络架构及知识概述
    K8s控制器 StatefulSet
    pod的数据持久化2 NFS
    Pod的数据持久化1 hostPath 和emptyDir
  • 原文地址:https://www.cnblogs.com/tianyumuhe/p/9029427.html
Copyright © 2011-2022 走看看