Reputation:
I'm having a text file in Resource folder and my robot script in sibling folder namely Test, I need to use the relative path otherwise I need to specify the path explicitly once I changed the project location.
TEST PROJECT (Root folder)
|
|_____ Resource (folder)
| |_____ MyProfile.txt
| |_____ MyPicture.jpg
|
|_____ Test (folder)
|_____ MyTest.robot
I want to access the MyProfile.txt
in MyTest.robot
using relative reference instead of absolute path.
Kindly assist me.
Upvotes: 3
Views: 23160
Reputation: 1
or another way, you may add the project root folder to the sys.path. it will search up the referenced resources from the root folder.
Upvotes: 0
Reputation: 4875
We can give the Relative path by using the following approach
${CURDIR}${/}..\\Resource\\MyProfile.txt
The ${CURDIR}
will return the path of where you are using this code, then we need to back track using the navigation operator ..\\
But if you use ${EXECDIR}
will return the path of the file is executing.
${EXECDIR}${/}..\\Resource\\MyProfile.txt
Here the code and execution both are handled in a single file, so both the code will give you the appropriate location of MyProfile.txt
Upvotes: 10