Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of "If statement" in robot framework

How can we use if statement in robot framework. I would like to execute keyword only if it satisfies certain condition else it execute other code.

like image 489
user3068846 Avatar asked Jun 24 '15 09:06

user3068846


People also ask

How do you use if condition in robot framework?

END Use Run Keyword If in Robot Framework Run Keyword If ${True} Log This line IS executed. Run Keyword If ${False} Log This line is NOT executed. Use Run Keyword Unless in Robot Framework Run Keyword Unless ${True} Log This line is NOT executed. Run Keyword Unless ${False} Log This line IS executed.

What is an if statement in robotics?

Pseudocode of an if Statment: An if Statement allows your robot to make a decision. When your robot reaches an if Statment in the program, it evaluates the condition contained between the parenthesis. If the condition is true, any commands between the braces are run.

What are the 3 different types of variables in the robot framework?

There are three types of variables supported in robot framework − scalar, list and dictionary.

How do you break a loop in Robot Framework?

Breaking out of the for loop using BREAKUsing an IF condition and BREAK , we can stop the execution of the for loop and have our program continue after it.


1 Answers

This is described in the Robot Framework User Guide under the section Conditional Execution, where it mentions Run Keyword If and Run Keyword Unless among other solutions. Documentation for these can be found in the documentation for the BuiltIn keyword library.

Here is a brief example:

*** Test cases ***
| Example
| | ${result}= | Set variable | 42
| | Run keyword if | "${result}" == "42"
| | ... | log | the result is 42
| | ... | ELSE 
| | ... | log | the result is NOT 42
like image 164
Bryan Oakley Avatar answered Sep 17 '22 14:09

Bryan Oakley