Question

If I run Monkeyrunner manually and execute the following 3 commands:

from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice

device = MonkeyRunner.waitForConnection()

device.press('KEYCODE_HOME', MonkeyDevice.DOWN_AND_UP)

Everything works, I see that the home key is pressed. However, if I save those 3 commands into a .py file, and then try to run the file, I get the following:

....\MonkeyRunner Scripts>monkeyrunner BasicTest.py
Can't open specified script file
Usage: monkeyrunner [options] SCRIPT_FILE

    -s      MonkeyServer IP Address.
    -p      MonkeyServer TCP Port.
    -v      MonkeyServer Logging level (ALL, FINEST, FINER, FINE, CONFIG, INFO,
WARNING, SEVERE, OFF)

I decided to try the -v switch to see what it say's, and I got the following:

....\MonkeyRunner Scripts>monkeyrunner -v BasicTest.
py
Exception in thread "main" java.lang.IllegalArgumentException: Bad level "BasicT
est.py"
        at java.util.logging.Level.parse(Unknown Source)
        at com.android.monkeyrunner.MonkeyRunnerOptions.processOptions(MonkeyRun
nerOptions.java:130)
        at com.android.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter
.java:179)

Any ideas on what's going on here?

Was it helpful?

Solution

I've figured it out. It doesn't make a whole lot of sense, but the only way I can get the scripts to work is run monkeyrunner from it's directory, rather than placing the path to monkeyrunner in my PATH. Also, the script itself also has to be in the same directly as the monkeyrunner.exe.

Does this make any sense to anyone out there?

OTHER TIPS

it works on any folder sending the content of the file as input

monkeyrunner < ./my_script.py

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top