Robot Framework: Is there any way to re-initialize variables which depend on other variable initiallized during test execution

StackOverflow https://stackoverflow.com/questions/22344561

  •  13-06-2023
  •  | 
  •  

Question

I have two global variables with the following default value:

${APP_INSTALL_DIR} = "%{ProgramFiles(x86)}\\application_name"
${APP_LAUNCH_PATH} = "${APP_INSTALL_DIR}\\app.exe"

These variables first initialized at test launch.

Then I re-initialize ${APP_INSTALL_DIR} variable during test execution with C:\\Folder\\application_name value using Set Global Variable keyword.

Is there any way to re-initialize ${APP_LAUNCH_PATH} variable automatically?

Now when ${APP_INSTALL_DIR} is changed, ${APP_LAUNCH_PATH} is not changed and has initial value %{ProgramFiles(x86)}\\application_name\\app.exe

Was it helpful?

Solution

No, there is no way to have variables automatically updated when other variables change.

What you can do instead is create a custom keyword that changes all the variables at once.

*** Keywords ***
| Reset app directory
| | [Arguments] | ${path}
| | Set global variable | ${APP_INSTALL_DIR} | ${path}
| | Set global variable | ${APP_LAUNCH_PATH} | ${APP_INSTALL_DIR}\\app.exe
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top