Reputation: 107
In the BuiltIn library, there are a ton of "Run keyword If.." commands, but I don't want to test a condition and then run a keyword. Is it possible to use the conditional "if" or "else" without involving keywords?
Upvotes: 1
Views: 6930
Reputation: 385860
It appears you misunderstand how robot works. Everything you do in robot is with keywords. Robot framework isn't a programming language, it's a keyword driven framework. Its only purpose is to run keywords.
If you want to run click element
based on a condition, you do it with run keyword if
since click element
is itself a keyword.
For example:
*** Test Cases ***
Examples
Run keyword if '${PO_Dictionary.ExistingMember}' == 'Yes'
... Click Element ${EXISTING_MEMBER_YES_RADIO}
... ELSE
... Click Element ${EXISTING_MEMBER_NO_RADIO}
Unfortunately, running multiple commands in an if statement is difficult. If you only want to run Input Text ${ZIP_TEXT} ${PO_Dictionary.ZipCode}
in the else clause, you have to either call run keywords
or create a small keyword.
For example:
*** Test Cases ***
Examples
run keyword if '${PO_Dictionary.ExistingMember}' == 'Yes'
... Click Element ${EXISTING_MEMBER_YES_RADIO}
... ELSE Run keywords
... Click Element ${EXISTING_MEMBER_NO_RADIO}
... AND Input Text ${ZIP_TEXT} ${PO_Dictionary.ZipCode}
Upvotes: 3