1
votes

I have a scenario where i need to set a variable value based on the input.

If input is 'A', i need to set ${var} = valA

If input is 'B', i need to set ${var} = valB

So i have following code

${columnObject}=    Run Keyword If  '${sortBy}'=='A'    Set Variable    valA
${columnObject}=    Run Keyword If  '${sortBy}'=='B'    Set Variable    valB

I am getting ${columnObject} as None if ${sortBy} has value 'A' as its also executing second statement and setting ${columnObject}

1

1 Answers

3
votes

You can use the keyword Set Variable If

${columnObject}=    Set Variable If    '${sortBy}'=='A'    valA
...     '${sortBy}'=='B'    valB

${sortBy} will be assigned to None if neither of those conditions are met.