简体   繁体   中英

How to pass a variable file path to Robot Framework located on PYTHONPATH?

Environment: Robot Framework 2.7.5 (Jython 2.5.2 on java1.6.0_21) Tomcat 7.0.32

Hi,

I am using RF embedded on a Java web application and am I having issues passing the --variablefile argument into the RobotRunner API.

According to User Guide, "Similarly to resource files, the path to the imported variable file is considered relative to the directory where the importing file is, and if not found, it is searched from the directories in PYTHONPATH". My variable file is located on /my/server/apache-tomcat-7.0.32/webapps/myapp/WEB-INF/lib/Lib and I have been able so far to call a listener interface placing it either on the PYTHONPATH or the CLASSPATH, but apparently the variable file is not found unless using only an absolute path to it.

PYTHONPATH:
    /my/server/apache-tomcat-7.0.32/webapps/myapp/WEB-INF/lib/robotframework-2.7.5.jar/Lib/robot/libraries
    /my/server/apache-tomcat-7.0.32/webapps/myapp/WEB-INF/lib/robotframework-2.7.5.jar/Lib
    /my/server/apache-tomcat-7.0.32/webapps/myapp/WEB-INF/lib/Lib
    __classpath__
    __pyclasspath__/
    .
    /my/server/apache-tomcat-7.0.32/bin
CLASSPATH:
    /my/server/apache-tomcat-7.0.32/bin/bootstrap.jar
    /my/server/apache-tomcat-7.0.32/bin/tomcat-juli.jar

Whenever I try to run the test passing the argument, i get the below error message:

.../robotframework>java -jar robotframework-2.7.5.jar --listener myListener --variable MYPARAM:sit --variablefile myVariableFile.py path\to\my\test

[ ERROR ] Importing variable file 'myVariableFile.py' failed: File or directory does not exist.

Since this is a web application, it wouldn't be good to set an absolute path to the variable file and is better to be able to rely on the PYTHONPATH directories for a search.

This issue has been reported as a bug (by the author of this question, I presume...). The author of robotframework confirmed that the current behavior is to not search PYTHONPATH for variablefiles specified on the command line.

For more information and to see if this has been fixed, go to the robotframework issue tracker for issue #1401

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM