Skip to content
Advertisement

IF ELSE in robot framework [Keyword as a condition]

I just can’t figure out how to map a keyword as a condition.

JavaScript

The above function returns a bool value either True or False.

“Is the Closed Message Page Present” is a keyword which I want to make condition. If the condition is true then it should execute the below two keywords else skip it.

JavaScript

I tried following:

JavaScript
JavaScript
JavaScript

I am expecting the keyword (Is the Closed Message Page Present) to be condition which needs to be true to execute the other two statements or keywords.

Advertisement

Answer

I’m still new to the framework, but the only simple method I found is to store the keyword return value to a local variable and use that in the IF statement.

JavaScript

stackoverflow.py returns a random True/False value

JavaScript

There is an exhaustive list of conditional expressions that you could further use at https://robocorp.com/docs/languages-and-frameworks/robot-framework/conditional-execution

Advertisement