To expand on Bryan's answer and add clarification for those of you not specifically interested in creating a suite variable based on the results of a keyword, there are other ways to initialize "global" variables at the start of a Robot Framework test.
The easiest way is to put them under a Variables header.
*** Variables ***
${this_string} This String
${that_int} 5
An alternative way to do that is to put the same variables in a Resource .txt file. Once it's called under *** Settings ***
, the variables can be used freely. Assuming you have your variables in a file called VarList.txt
, the following code will initialize them:
*** Settings ***
Resource VarList.txt
Should you be using a Resource file with existing keywords and internal variables, this will also work for that.
This all assumes you want static variables. Set Suite Variable and Set Global Variable can both be used with keywords like Bryan said. Set Suite Variable works well for scripts with multiple test Suites, while Set Global Variable should be used extra sparingly in that case. In a single-Suite script, however, the differences are all but negligible, though best practice would be to stick with Set Suite Variable unless you really want it to be global, just on the off-chance you decide to add that Suite to a script running multiple Suites.