Reputation:
I have one test suit with two test cases. I have one same-name variable between the two test cases, let's say ${X}
. The first test case changes the value of this variable. The second test case, gives me the following error Variable '${X}' not found
.
How can I have something like a Global Variable? Like if it is defined in one test case, the next test case will recognize this variable and use the new value and so on
Upvotes: 9
Views: 41956
Reputation: 766
Try this,when ever you are trying to change the value of variable then make that variable Global, this meets your requirement so when the variables are logged in the below example it has the latest value stored in the variable.
*** Test Cases ***
Test1
${test}= Evaluate 9
Set Global Variable ${test}
Test2
${test}= Evaluate 10
Set Global Variable ${test}
Test
Log Variables
Upvotes: 26
Reputation: 2194
You probably need a suite level variable to share the value across the tests. From your description it is not clear if your tests are under the same test suites or different.
http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Set%20Suite%20Variable
Upvotes: 4