Reproduce Android Monkey Script
Asked Answered
P

1

5

I ran the Monkey tool (the tool to perform stress testing on Android application) and I got some script file that have this form:

type= raw events
count= -1
speed= 1.0
start data >>
LaunchActivity(com.amaze.filemanager,com.amaze.filemanager.activities.MainActivity)
DispatchPointer(6934862,6934862,0,517.0,124.0,0.0,0.0,0,1.0,1.0,0,0)
DispatchPointer(6934862,6934867,1,520.041,127.07279,0.0,0.0,0,1.0,1.0,0,0)
GUIGen(3)
DispatchTrackball(-1,6945789,2,1.0,-3.0,0.0,0.0,0,1.0,1.0,0,0)
...

I would like to re-execute such sequence of events again, using the produced script. How can I do that?

Petiolate answered 10/10, 2017 at 14:38 Comment(3)
Just curious here, how where you able to get this script from the Monkey tool ?Gulp
Do you want to loop your script file for a certain no of time?Deflate
@Gulp I just run monkey from the command line, with a desired verbosity level and number of input, redirecting the output on a text filePetiolate
S
6

You will need adb for the same. First you will create the file on your local

monkey.script

type= raw events
count= -1
speed= 1.0
start data >>
LaunchActivity(com.amaze.filemanager,com.amaze.filemanager.activities.MainActivity)
DispatchPointer(6934862,6934862,0,517.0,124.0,0.0,0.0,0,1.0,1.0,0,0)
DispatchPointer(6934862,6934867,1,520.041,127.07279,0.0,0.0,0,1.0,1.0,0,0)
GUIGen(3)
DispatchTrackball(-1,6945789,2,1.0,-3.0,0.0,0.0,0,1.0,1.0,0,0)

Then you will copy it to your phone

adb push ./monkey.script /sdcard/Download

And then you can run the script from adb

$ adb shell monkey -f /sdcard/Download/monkey.script 1
Events injected: 4
## Network stats: elapsed time=10ms (0ms mobile, 0ms wifi, 10ms not connected)
Stercoraceous answered 19/4, 2018 at 21:11 Comment(5)
Any explanation on the downvote? Please comment while downvoting. This has been tested before postingStercoraceous
thankyou for suggesting the script. Can you please give me some link or material to study further. I am also working on automation and need helpEverett
You can start here youtube.com/watch?v=Vt8EUQtqBuAStercoraceous
I checked the video, Actaully I need documentation for the command which I can use in my scriptEverett
I checked the video, Actually I need documentation for the command which I can use in my script, like what does "GUIGen" command means and what is the meaning of count = -1 in your code.Everett

© 2022 - 2024 — McMap. All rights reserved.