NikS
NikS

Reputation: 149

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

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

Upvotes: 0

Views: 1194

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 385980

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

Upvotes: 1

Related Questions