Forum Discussion

gdave's avatar
gdave
Regular Contributor
7 years ago

Set Variable Value

Hi all

 

I used the Operation 'Set variable Value' and created an empty variable at test level for the value to display in 'Default Value' field however my test run successfully but I couldn't see any value in the 'Default Value' field of the variable.

Now when I run the same test by setting the variable at project level then it works fine.

 

Can anyone please explain why there is inconsistency in the behaviour of the output displayed at test level compare to project level. Thanks

6 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Variables on the test level are just like writing variables in code.  The "default value" is simply what the value of the variable is if you don't set it to something else.  So, when you set the variable value in the test, it will assign it whatever you assign it... it will not change the "default value".  That's something you need to edit when you add the variable to the keyword test... default value is not affected by the code.

     

    • gdave's avatar
      gdave
      Regular Contributor

      But my main issue is that no value is being populated in the 'default value' field of the variable upon using set variable operation. Thanks

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Correct.  "Set Variable Value" does not alter the default value of the variable.  It sets the run-time value of the variable to whatever you have determined in the "Set Variable Value" operation.  That is by design.  If you want to alter the default value of a keyword test variable, that is done at design time in the keyword test editor.

         

        As for Project variables...  This depends upon what "kind" of project variable it is.  There are actually two kinds: Temporary and Persistent.  Temporary variables have a "Default" value much like what is done with the Keyword test variables.  It's set at the time the variable is created and is used if the variable value is not updated by any code.  However, code itself does not change the default value.

         

        Persistent project variables, however... their "Default" value is not exactly a default.  It is what is set in the "Local" value when the variable is first used.  If you set the variable value during code, that local value changes and is persisted from test run to test run.