androidmonkey

Reproduce Android Monkey Script


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?


Solution

  • 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)