RajKon
RajKon

Reputation: 470

how do I assign a variable based on condition in robotframework

Here is the pseudo code which I would like to write using Robot Framework. If it cannot be done using the framework is there any alternative:

${balMethodID}=   Set Variable If  ${balMethodID} == None  ${newBalMethodID}

Basically if the value of variable is None then I want to assign a new value. The value of the variable is becoming None when its initial value is not None.

enter image description here

Upvotes: 4

Views: 7541

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 385970

Set Value If can be given two values; the first will be used if the condition is true, the second is if the condition is false. If you want to keep the original value if the condition is false, use the original value as the last argument:

${balMethodID}=   Set Variable If  ${balMethodID} == None 
...  # value if true    # value if false 
...  ${newBalMethodID}  ${balMethodID}

Upvotes: 5

Related Questions