Compare FALSE expression in Robot Framework test cases
I have a problem canceling a bool variable or comparing FALSE to a bool variable to do Run Keyword If
My code
Test Case
${isExist}= Run Keyword And Return Status Element Should Be Visible ${element_Id}
Run Keyword If ${isExist} == false click element ${cancelbtn}
Here I ran into a runtime error
Evaluating the expression "True" and "Failed": SyntaxError: unexpected EOF while parsing (, line 1)
I tried the following comparison too
-
${isExist} == 'false'
-
'${isExist}' == 'false'
-
${isExist} == ${false}
-
'${isExist}' == '${false}'
-
!${isExist}
Note: log to console ${isExist}
- It registers the corresponding Boolean value in the console window.
source to share
if ${isExist}
boolean you can usenot
Run Keyword If not ${isExist} ...
You can also compare with ${FALSE}
or ${TRUE}
:
Run Keyword If ${isExist} is ${FALSE} ...
Run Keyword If ${isExist} is not ${TRUE} ...
You say it ${isExist} == ${false}
doesn't work, but it will if {isExist}
indeed a boolean value False
.
Note: ${FALSE}
and ${TRUE}
are variables defined by the robot. They are mentioned briefly in the documentation under Boolean and None / null variables in the Robot User Guide.
source to share