我们如何在机器人框架中使用if语句。
我想仅当关键字满足某些条件时才执行它,否则它会执行其他代码。
这在机器人框架用户指南 http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html在该部分下条件执行 http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#conditional-execution,其中提到运行关键字 If http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Run%20Keyword%20If and 运行关键字除非 http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Run%20Keyword%20UnlesT除其他解决方案外。这些文档可以在以下文档中找到内置关键词库 http://robotframework.org/robotframework/latest/libraries/BuiltIn.html.
这是一个简短的例子:
*** Test cases ***
| Example
| | ${result}= | Set variable | 42
| | Run keyword if | "${result}" == "42"
| | ... | log | the result is 42
| | ... | ELSE
| | ... | log | the result is NOT 42
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)