To import Variables and Resources we are using relative path to the location where Variables and Resources are present.
I am using .py files to keep variables and .robot files to maintain resources
And using relative paths like.-> …/…/Resources/TestDataFiles/LoginPage.robot
It’s difficult to maintain the relative path if we have to import huge number of Variables and Resources file. In some cases we may have to import 50 or more than 100 files. So have to write 100 lines of import using relative path.
Now if there is a change in location of the file then I will have to update the location in all the places where I am using the relative path to the file.
Is there any better approach for this?
Instead of writing the relative path and moving backward or forward direction can we use the project root path and then move from there.
Not sure how we can get project root path using robot framework.
${CURDIR} isn’t helping me in this case. It’s giving the path to the directory where i am using it.
But the Variables and resource files which i am trying to access are not present inside the current directory. They are present outside of the current directory.
Again i have to use the relative references to get those resources.
How about in the resources folder you create a main.robot that you import in all your robot tests, this main.robot file then has all the imports for the other resoiurce files that your tests need, then if a resource file is moved you update just main.robot and all your test cases can stay the same.
${CURDIR} would be p:\my_project\tests\regression\my_test_suite\functional_area_a\test_cases
${EXECDIR} would be c:\users\Subha
But perhaps you would refer to p:\my_project\tests\regression\my_test_suite as the “project root path”? If that’s the case no there’s no built in variable for that but you could easily determine what it is with Normalize Path. Something like this should give you what you need: