android monkey runner scripts

前端 未结 6 1302
终归单人心
终归单人心 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: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% %*
    

提交回复
热议问题