Cannot use new variables from *.py file

Hello

I do my first steps with Robot Framework in PyCharm.
I have some variables in a variables.py file and use them in test.robot file:

*** Settings ***

Variables …/variables.py

This is working for existing variables.
The problem is for new created or changed variables . I cannot us them as expected. They are marked as undefined in the robot file. I have to restart the IDE to get them known in the robot file.
Any idea how to solve?

Thanks, Rüdiger

Hi Rüdiger,

Can you include your variables.py putting a comment next to a variable that is not working as expected and the and a variable that that is working so we can have a chance of figuring out what is happening.

Dave.

Hi Dave, I think attaching the variable file wouldn’t make it any clearer.
I have a file locators.py containing css and/or xpath locator, e.g:

SEND_MESSAGE = ‘text=file_upload’
OTP_REQUEST = ‘button:has-text(“OTP anfordern”)’

I use this variables in a robot file, e.g.:

*** Settings ***
Library Browser
Variables …/locator/locators.py

*** Keywords ***
Send Test
Click ${SEND_MESSAGE}

Now I add a new variable to the locators.py. Problem: I cannot use the new variable in robot file. It is marked as undefined until I restarted pyCharm. I think it is a pyCharm problem. Configuration?

Rüdiger

To me this would indicate that the issue is within your IDE (pycharm) and the issue would not happen during actual test/task run. And if thats the case, there’s pretty much robot specific that could be done here because its the pycharm that doesn’t reload / reinterpret the variable file if/when its modified…

My suggestions: try vscode with robotframework lsp or don’t rely on IDE hints …

1 Like

Yes, you are right. No problem for test run. I hope there is a configuration in pyCharm/RobotFramework plugin to detect changes in python library and trigger reload / reinterpret…

What plugin are you using? I suggest only using the “Robot Framework Language Server” plugin as your plugin for RF in Pycharm.

Yes, I use only this plugin.