码迷,mamicode.com
首页 > 其他好文 > 详细

Monkey写脚本

时间:2018-05-12 19:20:07      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:结果   应用   type   pat   start   连续   测试   androi   dispatch   

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

Monkey写脚本

标签:结果   应用   type   pat   start   连续   测试   androi   dispatch   

原文地址:https://www.cnblogs.com/tianyumuhe/p/9029427.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!