rf-practice
IF Statements

Context

Real automation rarely follows a single straight path. Conditions let a test or keyword choose different actions depending on the current state, such as a variable value or an earlier result.

Theory

Robot Framework uses IF, optional ELSE IF and ELSE branches, and a closing END to create conditional blocks. The condition is a Python expression, so comparisons like ${number} > 0 are evaluated directly by the framework.

Task

  • Create a *** Keywords *** section with a keyword Check Number.
  • Check Number should accept ${number} and return positive when ${number} > 0.
  • Otherwise it should return non-positive.
  • Create test cases IF Test Positive and IF Test Negative.

Checks

Defines a *** Keywords *** section
Defines a keyword named Check Number
Check Number uses an IF block
Check Number uses an ELSE branch
Returns positive for numbers greater than 0
Returns non-positive for other numbers
Has a test case named IF Test Positive
Has a test case named IF Test Negative
IF Test Positive passes
IF Test Negative passes