Pass variables from one test case to another in Robot framework (Global variable)

31,395

Solution 1

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

Solution 2

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

Share:
31,395
Admin
Author by

Admin

Updated on July 09, 2022

Comments

  • Admin
    Admin almost 2 years

    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