首页 > 其他 > 详细

Monkey写脚本

时间:2018-05-12 18:46:58      阅读:152      评论:0      收藏:0      [点我收藏+]

今天学习使用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写脚本

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

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