Prashant Gurjar
Prashant Gurjar

Reputation: 37

How to re initiate Variable value in RobotFramework in mid of test case

I have some variables defined in Resource file.

*** Variables *** 
${x}       SomeValue
# Derived String
${y}       SomeString_${x}

After using this in existing test case I modified ${x}. After same am able to use ${x} as modified variable but ${y} remain unchanged. Do we have some way to re initiate ${y} as per new ${x}.

Upvotes: 1

Views: 4382

Answers (1)

Todor Minakov
Todor Minakov

Reputation: 20067

Short answer - not automatically; the value of ${y} will remain as is, regardless that ${x} changed.

The reason is the values in the Variables section are set once, on instantiating the suite. At that time the value of ${y} is set to "SomeString_the-current-value-of-x", and that's it; e.g. it's not some kind of pointer to the present value of ${x}, changing as ${x} changes.

If you want to re-set the value of y, you can do it after you've changed x:

${y}=    Set Variable    SomeString_${x}

Upvotes: 5

Related Questions