4

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

1 Answer 1

5

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}
Sign up to request clarification or add additional context in comments.

1 Comment

This is more robust as it can be reused that I wrote in python. It could be used in Robot file. def set_variable_if_no_value_or_none(given_var, to_value): if given_var == 'None' or given_var is None or given_var == "": return to_value else: return given_var

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.