robotframework - 如何在机器人框架中同时使用 And 和 Or 条件
问题描述
运行关键字
If '${Contains_True}' == 'true'
and
'${App_Name}' == 'App Name'
Accept_Confidential
ELSE IF '${Contains_True}' == 'true'
"Do Something" ELSE Log "Nothing"
解决方案
在下面的示例中,针对使用和/或验证来验证组合的关键字来测试不同的组合。请记住,这种和/或检查也可以是单独的ELSE IF
语句。
*** Test Cases ***
TC
[Template] Validate App and Contains
App Name true
App Name false
My app Name true
My app Name false
Not My Name true
Not My Name false
*** Keywords ***
Validate App and Contains
[Arguments] ${App_Name} ${Contains_True}
Run Keyword If
... ('${Contains_True}'=='true' and '${App_Name}'=='App Name') or '${App_Name}'=='My app Name' Return From Keyword Accept
... ELSE IF '${Contains_True}'== 'true' Log App Name is not as expected:"${App_Name}" level=WARN console=${True}
... ELSE Fail Of the combo "${App_Name}"/"${Contains_True}" None of the values are correct.
推荐阅读
- c# - 在 MySQL.Data.EntityFrameworkCore 中找不到 Extensions 命名空间
- typescript - 在 TypeScript 中给定泛型类型或参数时,如何缩小函数响应的类型
- javascript - 带有脚本的 PHP 表单不执行 POST
- python - 向前矢量化 PyTorch 操作
- python - 如何将用户可配置的 dict 传递给类实例
- android - 与模态类的 LiveData 对象的双向数据绑定
- swift - KVC - 检查属性是否存在
- php - Laravel 数据库连接(保存数据)
- python - 为什么我的python服务器将post请求数据保存为“0”?
- extjs - 动态创建 ExtJS 表单以进行页面重定向