Reputation: 47
i'm trying to use les if in robot framework like this:
${url}= Set Variable If '${prefix}'== 'aaa' ${host1}
... ELSEIF '${prefix}'== 'bbb' ${host2}
... ELSEIF '${prefix}'== 'ccc' ${host3}
When i excute it fails with this message: Evaluating expression 'ELSE IF' failed: SyntaxError: unexpected EOF while parsing (, line 1) ]
Upvotes: 1
Views: 1416
Reputation: 386342
You can't use ELSE IF when using Set Variable If
. If you have multiple conditions, simply add them without the ELSE IF.
From the official keyword documentation:
It is also possible to have 'else if' support by replacing the second value with another condition, and having two new values after it. If the first condition is not true, the second is evaluated and one of the values after it is returned based on its truth value. This can be continued by adding more conditions without a limit.
Example:
${url}= Set variable if
... '${prefix}'== 'aaa' ${host1}
... '${prefix}'== 'bbb' ${host2}
... '${prefix}'== 'ccc' ${host3}
Upvotes: 1