我有问题否定bool变量或FALSE与要执行的bool变量的比较 Run Keyword If
我的代码是
Test Case
${isExist}= Run Keyword And Return Status Element Should Be Visible ${element_Id}
Run Keyword If ${isExist} == false click element ${cancelbtn}
Run Code Online (Sandbox Code Playgroud)
在这里,我面临运行时错误
评估表达式'True和'失败:SyntaxError:解析时的意外EOF(,第1行)
我也尝试了以下比较
${isExist} == 'false' '${isExist}' == 'false' ${isExist} == ${false} '${isExist}' == '${false}' !${isExist}注意:log to console ${isExist}- 它在控制台窗口中记录相应的布尔值.
if ${isExist}是布尔值,你可以使用not
Run Keyword If not ${isExist} ...
Run Code Online (Sandbox Code Playgroud)
你也可以比较${FALSE}或${TRUE}:
Run Keyword If ${isExist} is ${FALSE} ...
Run Keyword If ${isExist} is not ${TRUE} ...
Run Code Online (Sandbox Code Playgroud)
你说这${isExist} == ${false}不起作用,但它{isExist}确实是布尔值False.
注意:${FALSE}并且${TRUE}是由机器人定义的变量.它们在机器人框架用户指南中标题为Boolean和None/null变量的部分的文档中简要提及.