android monkey runner scripts

前端 未结 6 1297
终归单人心
终归单人心 2021-02-14 11:05

i am tryig to execute a sample python program through monkey runner command prompt and it is throwing an error

Can\'t open specified script file
Usage: monkeyrun         


        
相关标签:
6条回答
  • 2021-02-14 11:41

    monkeyrunner.bat cygpath -w $(pwd)/monkey.py

    0 讨论(0)
  • 2021-02-14 11:44

    scriptfile should be a full path file name try below monkeyrunner c:\test_script\first.py

    0 讨论(0)
  • 2021-02-14 11:45

    try using something like

    ...\tools>monkeyrunner -v ALL first.py
    

    where first.py was my sample python script which I copied into tools folder of android SDK (the place where monkeyrunner.bat is located)

    0 讨论(0)
  • 2021-02-14 11:55

    I met the same things as you did, I resolved by using "monkeyrunner" command under tools, and your script file should be a full path name. It looks like the directory “tools” is the main directory of MonnkeyRunner. I am depressed that I can't run my script files by pydev IDE directly.

    0 讨论(0)
  • 2021-02-14 11:56

    It looks not make sense to switch working directory to Android SDK folder but just for obtain some relative references path for itself. It means you have to specify the full path for your script file and the PNG image files you want to save or compare to.

    A better way is modify few lines in the "monkeyrunner.bat" under your SDK folder as below. This will use your current path as working directory, so, no necessary to use full path file name.

        rem don't modify the caller's environment
    setlocal
    
    rem Set up prog to be the path of this script, including following symlinks,
    rem and set up progdir to be the fully-qualified pathname of its directory.
    set prog=%~f0
    
    rem Change current directory and drive to where the script is, to avoid
    rem issues with directories containing whitespaces.
    rem cd /d %~dp0
    
    rem Check we have a valid Java.exe in the path.
    set java_exe=
    call %~sdp0\lib\find_java.bat
    if not defined java_exe goto :EOF
    
    set jarfile=monkeyrunner.jar
    set frameworkdir=
    set libdir=
    
    
    if exist %frameworkdir%%jarfile% goto JarFileOk
        set frameworkdir=%~sdp0\lib\
    
    if exist %frameworkdir%%jarfile% goto JarFileOk
        set frameworkdir=%~sdp0\..\framework\
    
    :JarFileOk
    
    set jarpath=%frameworkdir%%jarfile%
    
    if not defined ANDROID_SWT goto QueryArch
        set swt_path=%ANDROID_SWT%
        goto SwtDone
    
    :QueryArch
    
        for /f %%a in ('%java_exe% -jar %frameworkdir%archquery.jar') do set swt_path=%frameworkdir%%%a
    
    :SwtDone
    
    if exist %swt_path% goto SetPath
        echo SWT folder '%swt_path%' does not exist.
        echo Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.
        exit /B
    
    :SetPath
    
    call %java_exe% -Xmx512m -Djava.ext.dirs=%frameworkdir%;%swt_path% -Dcom.android.monkeyrunner.bindir=%frameworkdir%\..\..\platform-tools\ -jar %jarpath% %*
    
    0 讨论(0)
  • 2021-02-14 11:59

    Under all unix/linux families OS the sha bang syntax can be used.

    Edit the first line of your script with the results of the following command:

    which monkeyrunner
    

    for example, if monkeyrunner (usually provided with android sdk) has been installed under /usr/local/bin/sdk write:

    #!/usr/local/bin/sdk/tools/monkeyrunner
    

    or even use "env"

    #!/usr/bin/env monkeyrunner
    

    then set you script file as executable

    chmod +x <script>
    

    You can now launch your script from the shell.

    0 讨论(0)
提交回复
热议问题