1

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) ]

1
  • Have you tried without the ELSEIF? The examples in the guide don’t have them. Commented Nov 6, 2018 at 21:26

1 Answer 1

1

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

Comments

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.