Home > other >  Multiple Conditions IF/ELSE statement Robot Framework 4
Multiple Conditions IF/ELSE statement Robot Framework 4

Time:11-09

In RobotFramework 4 we can now write a more traditional looking if/else statement.

So something like:

*** Keywords ***
Do conditional execution
IF ${CONDITION}
Log True!
ELSE IF "cat" == "dog"
Log Dog!
ELSE
Log Not True!
END

Does anyone know how to write it with multiple conditions? Im currently working on something. If I write multiple statements like so, it works

        IF  "${error1}" == "False"
            Do Something

        ELSE IF  "${error2}" == "False"
            Do Something

        ELSE IF  "${error3}" == "False"
            Do Something

but if I try write it like this

IF  "${error1}" == "False"  or  "${error2}" == "False"  or    "${error3}" == "False"
   Write To Google Document

Then it tells me

IF has more than one condition.

Any ideas if I'm writing it wrong? Or is there a better way?

CodePudding user response:

In your code you have two spaces before "or". You can't two or more spaces in your expression. You have "or or" in your expression.

This should work:

IF  "${error1}" == "False" or "${error2}" == "False" or "${error3}" == "False"
   Write To Google Document
  • Related