monkeyScript测试

连接手机
在test.script位置按住shift+鼠标右键,打开cmd或powershell窗口


输入指令:adb push test.script /data/local/tmp/     把test.script添加到/data/local/tmp/ 路径下


再输入指令执行脚本(2为执行的次数):adb shell monkey -f /data/local/tmp/test.script  2


可以依次通过指令进入手机查看是否有script:
1:adb shell  


2:cd /data/local/tmp/ 


 3:ls   (L的小写)

test.script文件:

启动的Activity必须在AndroidManifest.xml添加  android:exported="true"  复制后把下面的注释去掉。

typ=user
count=10
speed=1.0
start data >>
//注释:前面四句好像统一的,具体不明白
//注释:LoginActivity加上包名
LaunchActivity(com.example.ewdatasystem_android,com.example.ewdatasystem_android.ui.user.LoginActivity)
//注释:等待2秒
UserWait(2000)
//注释:0,700,700:0:按下,1:松开; 700,700:指点击事件的x,y坐标(下面介绍如何获取700,700)
DispatchPointer(10,10,0,700,700,1,1,-1,1,1,0,0)
DispatchPointer(10,10,1,700,700,1,1,-1,1,1,0,0)
//注释:输入123
DispatchString(123)
//注释:66指点击键盘回车键输入123
DispatchPress(66)
UserWait(1000)
DispatchPointer(10,10,0,700,900,1,1,-1,1,1,0,0)
DispatchPointer(10,10,1,700,900,1,1,-1,1,1,0,0)
DispatchString(123)
DispatchPress(66)
UserWait(1000)
DispatchPointer(10,10,0,100,100,1,1,-1,1,1,0,0)
DispatchPointer(10,10,1,100,100,1,1,-1,1,1,0,0)
UserWait(1000)
DispatchPointer(10,10,0,500,1250,1,1,-1,1,1,0,0)
DispatchPointer(10,10,1,500,12500,1,1,-1,1,1,0,0)
UserWait(1000)

获取app点击位置例如700,700

1.androidstudio点击如下查看sdk位置,并打开。

2.找到里面的tools

3.双击打开uiautomatorviewer.bat (找不到就打开bin找找)

4.稍等片刻,接着打开手机图标

5.稍等片刻后显示下面连接手机的界面

6.点击输入框,显示红色边框;接着看右下绿框的bounds:左上角,右下角的x,y坐标值;x取值在354-984之间就行,y同理。

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值