Use of “If statement” in robot framework

﹥>﹥吖頭↗ 提交于 2019-12-12 09:44:21

问题


How can we use if statement in robot framework. I would like to execute keyword only if it satisfies certain condition else it execute other code.


回答1:


This is described in the Robot Framework User Guide under the section Conditional Execution, where it mentions Run Keyword If and Run Keyword Unless among other solutions. Documentation for these can be found in the documentation for the BuiltIn keyword library.

Here is a brief example:

*** Test cases ***
| Example
| | ${result}= | Set variable | 42
| | Run keyword if | "${result}" == "42"
| | ... | log | the result is 42
| | ... | ELSE 
| | ... | log | the result is NOT 42


来源:https://stackoverflow.com/questions/31023019/use-of-if-statement-in-robot-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!