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到底什么时候用呢?有哪位大神知道,请解下惑,不胜感激,谢谢。

  • 相关阅读:
    物联网操作系统HelloX V1.77(beta)版本发布
    对XX证券报关于物联网操作系统的几个问题的答复
    Android利用广播实现ViewPager中item之间的数据通信
    Android创建桌面快捷方式
    Android时间选择器对话框的使用
    Android数据库LitePal的存储操作
    Android创建数据表和LitePal的基本用法
    我的2014
    logstash 安装zabbix插件
    tag_on_failure => [] # prevent default _grokparsefailure tag on real records
  • 原文地址:https://www.cnblogs.com/tianyumuhe/p/9029427.html
Copyright © 2011-2022 走看看