android-studiotestingterminalmonkeyrunner

-bash: monkeyrunner: command not found


I am trying to see how monkeyrunnerworks. I have python script that I want to test it on my android virtual device. I tried running below command through terminal:

monkeyrunner script.py

I am at: /Users/myusername/Library/Android/sdk/tools/bin/monkeyrunner, python file is also in the same directory.

but it returns that: -bash: monkeyrunner: command not found

So I tried another way, and I opened monkeyrunner exec file, then tried to run script.py through it, but still giving this error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'script' is not defined

I also tried monkeyrunner script.py inside monkeyrunner exec file but gives this error:

File "<stdin>", line 1
    monkeyrunner script.py
                ^
SyntaxError: mismatched input 'script' expecting NEWLINE

Can anyone help, how to run a python script using androidstudio's monkeyrunner in MacOS and let me know what I am doing wrong.


Solution

  • Since I am new to macOS I wasn't sure that terminal kind of work the same as cmd on Windows, but after trying ./monkeyrunner script.py, finally my python script successfully run on monkeyrunner.

    Also I noticed another point that if someone else get stuck into this issue and doesn't like to put ./ every time he/she executes a command, he/she can just put the monkeyrunner path in his/her environment path variables.

    For macOS the paths file is here: /etc/paths