Python library imported only once

I have a python lib file which holds some wrapper function. This wrapper function loads a specific set of variables based on a robot variable. I use set_suite_variable in python function so that I can use in my robot test.

I call this python file as library inside a resource file and the resource file is called in my robot test script.

This worked fine for my scripts.

Now I created a test list grouping multiple robot scripts. Now when I tried to run it. The variables created by python lib works only on first test suite. In the subsequent test suites, I’m getting variable not found.

Hi Aravinth,

Is this resource file called by all the test cases or only the one?

If multiple, did you get an error from the second test that called the resource file?

Can you show some code example of what you are doing? it’s really hard to guess what your script would look like based on what you describe.

Dave.

1 Like

https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#library-scope

If your library scope is set to GLOBAL, it gets initialized only once and your description of an issue matches that behaviour. Try setting it to SUITE and see if that helps ?

2 Likes

Thanks everyone for the reply. Looks like I have wrongly understood the issue. The issue was I was trying to use the variable from resource file in Variables section

But in robot framework, variables imported from resource and variable files are not available in the Variable section of the file that imports them. This is due to the Variable section being processed before the Setting section where the resource files and variable files are imported.

2 Likes