'How to specify condition properly in the IF statement in Robot framework
I'm trying to use the IF and ELSE IF statements in ROBOT framework but i'm coming across the below error, what is correct syntax?
Select the All Events sub section as
[Arguments] ${screenName}
IF "${screenName}" == "safety"
click element ${safetyScreenButton}
ELSE IF "${screenName}" == "service"
click element ${serviceScreenButton}
ELSE IF "${screenName}" == "vehicle"
click element ${vehicleScreenButton}
ELSE IF "${screenName}" == "video requests"
click element ${videoRequestsScreenButton}
END
Verify safety screen under all events tab
[Tags] safetyScreenAllEventsTabTest
Navigate To All Events Tab
Select the All Events sub section as 'service'
Error- Multiple errors:
- IF has more than one condition.
- ELSE IF has more than one condition.
- ELSE IF has more than one condition.
- ELSE IF has more than one condition.
I tried removing the double quotes in the conditions but i get the same error.
Solution 1:[1]
I used the If condition in the below format and it worked.
Select the All Events sub section as
[Arguments] ${screenName}
run keyword if ${screenName}=="safety" click element ${safetyScreenButton}
run keyword if ${screenName}=="service" click element ${serviceScreenButton}
run keyword if ${screenName}=="vehicle" click element ${vehicleScreenButton}
run keyword if ${screenName}=="video requests" click element ${videoRequestsScreenButton}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Adarsh |
