Run customised android monkey test from adb shell

557 views Asked by At

I have written a monkey test .py file and I just want to run that file from "adb shell" rather then using monkeyrunner so is there any way to run monkey test python file from adb shell?

Below is the monkey --help section where I can see we can run scriptfile too

usage: monkey [-p ALLOWED_PACKAGE [-p ALLOWED_PACKAGE] ...]
              [-c MAIN_CATEGORY [-c MAIN_CATEGORY] ...]
              [--ignore-crashes] [--ignore-timeouts]
              [--ignore-security-exceptions]
              [--monitor-native-crashes] [--ignore-native-crashes]
              [--kill-process-after-error] [--hprof]
              [--match-description TEXT]
              [--pct-touch PERCENT] [--pct-motion PERCENT]
              [--pct-trackball PERCENT] [--pct-syskeys PERCENT]
              [--pct-nav PERCENT] [--pct-majornav PERCENT]
              [--pct-appswitch PERCENT] [--pct-flip PERCENT]
              [--pct-anyevent PERCENT] [--pct-pinchzoom PERCENT]
              [--pct-permission PERCENT]
              [--pkg-blacklist-file PACKAGE_BLACKLIST_FILE]
              [--pkg-whitelist-file PACKAGE_WHITELIST_FILE]
              [--wait-dbg] [--dbg-no-events]
              [--setup scriptfile] [-f scriptfile [-f scriptfile] ...] >> This might be helpful to run the file if i am not wrong
              [--port port]
              [-s SEED] [-v [-v] ...]
              [--throttle MILLISEC] [--randomize-throttle]
              [--profile-wait MILLISEC]
              [--device-sleep-time MILLISEC]
              [--randomize-script]
              [--script-log]
              [--bugreport]
              [--periodic-bugreport]
              [--permission-target-system]
              COUNT

I tried to run the file using command adb shell monkey -f test_monkey.py

but is showing error ** Error: Count not specified'

Please suggest the right direction need to follow. Thanks.

1

There are 1 answers

0
Diego Torres Milano On

monkey does not accept python scripts, as I may guess your intention was from the extension used.

The scripts are something like

type= raw events
count= 10
speed= 1.0
start data >>
captureDispatchPointer(5109520,5109520,0,230.75429,458.1814,0.20784314,0.06666667,0,0.0,0.0,65539,0)
captureDispatchKey(5113146,5113146,0,20,0,0,0,0)
captureDispatchFlip(true)

take a look at MonkeySourceScript.java.

Besides that, COUNT is not optional, so you should at least specify 1.