Reputation: 200
I am running the following keyword in the robot framework:
Welcome Page Should Be Open
Run Keyword If '${BROWSER}' == 'IE' Location Should Be ${LOGIN URL IE}
Run Keyword If '${BROWSER}' != 'IE' Location Should Be ${LOGIN URL}
Wait Until Page Contains Accounts 5s
Page Should Contain Accounts
Instead of having 2 Run Keyword If statements I was wondering if robot has a else statement that could be used or and OR statement that could be used?
Cheers
Upvotes: 3
Views: 13290
Reputation: 386010
Starting with version 2.7.4 of robot framework you can use ELSE when calling Run keyword if.
From the documentation:
Starting from Robot version 2.7.4, this keyword supports also optional ELSE and ELSE IF branches. Both of these are defined in *args and must use exactly format ELSE or ELSE IF, respectively. ELSE branches must contain first the name of the keyword to execute and then its possible arguments. ELSE IF branches must first contain a condition, like the first argument to this keyword, and then the keyword to execute and its possible arguments. It is possible to have ELSE branch after ELSE IF and to have multiple ELSE IF branches.
For example (for clarity I'm using the pipe separated format and continuation features):
| | Run Keyword If | '${BROWSER}' == 'IE'
| | ... | Location should be | ${LOGIN URL IE}
| | ... | ELSE
| | ... | Location should be | ${LOGIN_URL}
Upvotes: 4