Import Resource - File does not exist (Robot Framework)
First of all, you can get use ${CURDIR} and his friends.
${CURDIR} An absolute path to the directory where the test data file is located. This variable is case-sensitive.
${TEMPDIR} An absolute path to the system temporary directory. In UNIX-like systems this is typically /tmp, and in Windows c:\Documents and Settings\\Local Settings\Temp.
${EXECDIR} An absolute path to the directory where test execution was started from.
They can also be used in the declaration of the Import Resource. This should save you some problems.
I've used a different method in the past - by defining a global "required" variable that is the main project folder, and using it in all of the imports.
You can pass such a variable in the command line (and force your users to use a batch wrapper) or if you use the maven wrapper, you can put it there.
N.T.
Updated on July 18, 2022Comments
-
N.T. almost 2 years
Can you import files using Import Resource?
I need to be able to run the same testcases but using different variables to be able to run the same testcases in different languages. I have created different resource libraries to do this.
In order to tell my test cases which variable file I run a keyword to import only resource files for that country.
For example (This in the importAU text, which shares the same resource folder as the AU Resource.txt)
*** Keywords *** AU [Documentation] Initializes the AU keyword variables Import Resource ../variables/AU/Resource.txt
And then this is the setup txt (Opens the browser and runs the proper files)
*** Settings *** Library Selenium2Library Resource ../variables/US/Resource.txt Resource ../variables/AU/Resource.txt Resource ../variables/DE/Resource.txt *** Variables *** ${COUNTRY} AU //sets which country the file should run *** Keywords *** Homepage should be open Run Keyword AU Set Selenium Speed 1 second Open Browser ${url_staging} chrome Set log level TRACE Maximize Browser Window
I ran this and this is the error I get.
SETUP: setup.Homepage should be open Start / End / Elapsed: 20150707 18:56:35.038 / 20150707 18:56:35.048 / 00:00:00.010 00:00:00.009 KEYWORD: BuiltIn.Run Keyword AU Documentation: Executes the given keyword with the given arguments. Start / End / Elapsed: 20150707 18:56:35.039 / 20150707 18:56:35.048 / 00:00:00.009 00:00:00.007 KEYWORD: importau.AU Documentation: Initializes the AU keyword variables Start / End / Elapsed: 20150707 18:56:35.040 / 20150707 18:56:35.047 / 00:00:00.007 00:00:00.006 KEYWORD: BuiltIn.Import Resource ../variables/AU/Resource.txt Documentation: Imports a resource file with the given path. Start / End / Elapsed: 20150707 18:56:35.041 / 20150707 18:56:35.047 / 00:00:00.006 18:56:35.046 FAIL Resource file '..\variables\AU\Resource.txt' does not exist.
Did I do something wrong with the keyword or is the keyword faulty? I know this was a known issue as RobotFramework but it was supposedly fixed.
Here is the link: http://code.google.com/p/robotframework/issues/detail?id=944
-
N.T. almost 9 yearsI used the ${CURDIR} and it works! I didn't use it in the command line but I used it in the Import Resource parameter. Thank you so much!