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

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

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

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

monkeyScript测试
2:cd /data/local/tmp/ 

monkeyScript测试
 3:ls   (L的小写)

monkeyScript测试

test.script文件:

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

monkeyScript测试

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位置,并打开。

monkeyScript测试

monkeyScript测试

2.找到里面的tools

monkeyScript测试

3.双击打开uiautomatorviewer.bat

monkeyScript测试

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

monkeyScript测试

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

monkeyScript测试

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

monkeyScript测试

 

 

 

相关文章:

  • 2022-12-23
  • 2021-07-31
  • 2022-12-23
  • 2021-10-28
  • 2021-11-29
  • 2022-02-07
  • 2022-12-23
  • 2021-10-13
猜你喜欢
  • 2022-01-21
  • 2021-07-27
  • 2021-07-27
  • 2021-07-20
  • 2022-12-23
  • 2021-06-25
相关资源
相似解决方案