Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compare FALSE expression in Robot Framework Test Cases

I'm having issue in negate the bool variable or comparison of FALSE against a bool variable to perform Run Keyword If

My Code is

Test Case
    ${isExist}=  Run Keyword And Return Status    Element Should Be Visible    ${element_Id}
    Run Keyword If     ${isExist} == false    click element ${cancelbtn}

Here I'm facing an Run time error

Evaluating 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 logs the appropriate Boolean value in the console window.

like image 360
B.Balamanigandan Avatar asked Feb 04 '23 04:02

B.Balamanigandan


1 Answers

if ${isExist} is a boolean, you can use not

Run Keyword If     not ${isExist}     ...

You can also compare to ${FALSE} or ${TRUE}:

Run Keyword If     ${isExist} is ${FALSE}    ...
Run Keyword If     ${isExist} is not ${TRUE}  ... 

You say that ${isExist} == ${false} doesn't work, but it will if {isExist} is indeed the boolean value False.

Note: ${FALSE} and ${TRUE} are variables defined by robot. They are briefly mentioned in the documentation in the section titled Boolean and None/null variables in the robot framework user guide.

like image 159
Bryan Oakley Avatar answered Feb 06 '23 18:02

Bryan Oakley