Robot Framework
robot.libraries.BuiltIn._Control Class Reference
Inheritance diagram for robot.libraries.BuiltIn._Control:
robot.libraries.BuiltIn._BuiltInBase robot.libraries.BuiltIn.BuiltIn

Public Member Functions

def skip (self, msg='Skipped with Skip keyword.')
 Skips the rest of the current test. More...
 
def skip_if (self, condition, msg=None)
 Skips the rest of the current test if the condition is True. More...
 
def continue_for_loop (self)
 Skips the current FOR loop iteration and continues from the next. More...
 
def continue_for_loop_if (self, condition)
 Skips the current FOR loop iteration if the condition is true. More...
 
def exit_for_loop (self)
 Stops executing the enclosing FOR loop. More...
 
def exit_for_loop_if (self, condition)
 Stops executing the enclosing FOR loop if the condition is true. More...
 
def return_from_keyword (self, *return_values)
 Returns from the enclosing user keyword. More...
 
def return_from_keyword_if (self, condition, *return_values)
 Returns from the enclosing user keyword if condition is true. More...
 
def run_keyword_and_return (self, name, *args)
 Runs the specified keyword and returns from the enclosing user keyword. More...
 
def run_keyword_and_return_if (self, condition, name, *args)
 Runs the specified keyword and returns from the enclosing user keyword. More...
 
def pass_execution (self, message, *tags)
 Skips rest of the current test, setup, or teardown with PASS status. More...
 
def pass_execution_if (self, condition, message, *tags)
 Conditionally skips rest of the current test, setup, or teardown with PASS status. More...
 
def _return_from_keyword (self, return_values=None, failures=None)
 

Additional Inherited Members

- Properties inherited from robot.libraries.BuiltIn._BuiltInBase
 _context = property
 
 _namespace = property
 
 _variables = property
 

Detailed Description

Definition at line 2512 of file BuiltIn.py.

Member Function Documentation

◆ _return_from_keyword()

def robot.libraries.BuiltIn._Control._return_from_keyword (   self,
  return_values = None,
  failures = None 
)
private

Definition at line 2729 of file BuiltIn.py.

◆ continue_for_loop()

def robot.libraries.BuiltIn._Control.continue_for_loop (   self)

Skips the current FOR loop iteration and continues from the next.


NOTE: Robot Framework 5.0 added support for native CONTINUE statement that is recommended over this keyword. In the examples below, Continue For Loop can simply be replaced with CONTINUE. In addition to that, native IF syntax (new in RF 4.0) or inline IF syntax (new in RF 5.0) can be used instead of Run Keyword If. For example, the first example below could be written like this instead:

| IF '${var}' == 'CONTINUE' CONTINUE

This keyword will eventually be deprecated and removed.


Skips the remaining keywords in the current FOR loop iteration and continues from the next one. Starting from Robot Framework 5.0, this keyword can only be used inside a loop, not in a keyword used in a loop.

Example: | FOR | ${var} | IN |VALUES} | | | Run Keyword If | '${var}' == 'CONTINUE' | Continue For Loop | | | Do Something | ${var} | | END |

See Continue For Loop If to conditionally continue a FOR loop without using Run Keyword If or other wrapper keywords.

Definition at line 2564 of file BuiltIn.py.

◆ continue_for_loop_if()

def robot.libraries.BuiltIn._Control.continue_for_loop_if (   self,
  condition 
)

Skips the current FOR loop iteration if the condition is true.


NOTE: Robot Framework 5.0 added support for native CONTINUE statement and for inline IF, and that combination should be used instead of this keyword. For example, Continue For Loop If usage in the example below could be replaced with

| IF '${var}' == 'CONTINUE' CONTINUE

This keyword will eventually be deprecated and removed.


A wrapper for Continue For Loop to continue a FOR loop based on the given condition. The condition is evaluated using the same semantics as with Should Be True keyword.

Example: | FOR | ${var} | IN |VALUES} | | | Continue For Loop If | '${var}' == 'CONTINUE' | | | Do Something | ${var} | | END |

Definition at line 2595 of file BuiltIn.py.

◆ exit_for_loop()

def robot.libraries.BuiltIn._Control.exit_for_loop (   self)

Stops executing the enclosing FOR loop.


NOTE: Robot Framework 5.0 added support for native BREAK statement that is recommended over this keyword. In the examples below, Exit For Loop can simply be replaced with BREAK. In addition to that, native IF syntax (new in RF 4.0) or inline IF syntax (new in RF 5.0) can be used instead of Run Keyword If. For example, the first example below could be written like this instead:

| IF '${var}' == 'EXIT' BREAK

This keyword will eventually be deprecated and removed.


Exits the enclosing FOR loop and continues execution after it. Starting from Robot Framework 5.0, this keyword can only be used inside a loop, not in a keyword used in a loop.

Example: | FOR | ${var} | IN |VALUES} | | | Run Keyword If | '${var}' == 'EXIT' | Exit For Loop | | | Do Something | ${var} | | END |

See Exit For Loop If to conditionally exit a FOR loop without using Run Keyword If or other wrapper keywords.

Definition at line 2631 of file BuiltIn.py.

◆ exit_for_loop_if()

def robot.libraries.BuiltIn._Control.exit_for_loop_if (   self,
  condition 
)

Stops executing the enclosing FOR loop if the condition is true.


NOTE: Robot Framework 5.0 added support for native BREAK statement and for inline IF, and that combination should be used instead of this keyword. For example, Exit For Loop If usage in the example below could be replaced with

| IF '${var}' == 'EXIT' BREAK

This keyword will eventually be deprecated and removed.


A wrapper for Exit For Loop to exit a FOR loop based on the given condition. The condition is evaluated using the same semantics as with Should Be True keyword.

Example: | FOR | ${var} | IN |VALUES} | | | Exit For Loop If | '${var}' == 'EXIT' | | | Do Something | ${var} | | END |

Definition at line 2662 of file BuiltIn.py.

◆ pass_execution()

def robot.libraries.BuiltIn._Control.pass_execution (   self,
  message,
tags 
)

Skips rest of the current test, setup, or teardown with PASS status.

    This keyword can be used anywhere in the test data, but the place where
    used affects the behavior:

    - When used in any setup or teardown (suite, test or keyword), passes
      that setup or teardown. Possible keyword teardowns of the started
      keywords are executed. Does not affect execution or statuses
      otherwise.
    - When used in a test outside setup or teardown, passes that particular
      test case. Possible test and keyword teardowns are executed.

    Possible continuable failures before this keyword is used, as well as
    failures in executed teardowns, will fail the execution.

    It is mandatory to give a message explaining why execution was passed.
    By default the message is considered plain text, but starting it with
    ``*HTML*`` allows using HTML formatting.

    It is also possible to modify test tags passing tags after the message
    similarly as with `Fail` keyword. Tags starting with a hyphen
    (e.g. ``-regression``) are removed and others added. Tags are modified
    using `Set Tags` and `Remove Tags` internally, and the semantics
    setting and removing them are the same as with these keywords.

    Examples:
    | Pass Execution | All features available in this version tested. |
    | Pass Execution | Deprecated test. | deprecated | -regression    |

    This keyword is typically wrapped to some other keyword, such as
    `Run Keyword If`, to pass based on a condition. The most common case
    can be handled also with `Pass Execution If`:

    | Run Keyword If    | ${rc} < 0 | Pass Execution | Negative values are cool. |
    | Pass Execution If | ${rc} < 0 | Negative values are cool. |

    Passing execution in the middle of a test, setup or teardown should be
    used with care. In the worst case it leads to tests that skip all the
    parts that could actually uncover problems in the tested application.
    In cases where execution cannot continue do to external factors,
    it is often safer to fail the test case and make it non-critical.

Definition at line 2859 of file BuiltIn.py.

◆ pass_execution_if()

def robot.libraries.BuiltIn._Control.pass_execution_if (   self,
  condition,
  message,
tags 
)

Conditionally skips rest of the current test, setup, or teardown with PASS status.

    A wrapper for `Pass Execution` to skip rest of the current test,
    setup or teardown based the given ``condition``. The condition is
    evaluated similarly as with `Should Be True` keyword, and ``message``
    and ``*tags`` have same semantics as with `Pass Execution`.

    Example:
    | FOR | ${var}            | IN                     | @{VALUES}               |
    |     | Pass Execution If | '${var}' == 'EXPECTED' | Correct value was found |
    |     | Do Something      | ${var}                 |
    | END |

Definition at line 2882 of file BuiltIn.py.

◆ return_from_keyword()

def robot.libraries.BuiltIn._Control.return_from_keyword (   self,
return_values 
)

Returns from the enclosing user keyword.


NOTE: Robot Framework 5.0 added support for native RETURN statement that is recommended over this keyword. In the examples below, Return From Keyword can simply be replaced with RETURN. In addition to that, native IF syntax (new in RF 4.0) or inline IF syntax (new in RF 5.0) can be used instead of Run Keyword If. For example, the first example below could be written like this instead:

| IF ${rc} < 0 RETURN

This keyword will eventually be deprecated and removed.


This keyword can be used to return from a user keyword with PASS status without executing it fully. It is also possible to return values similarly as with the [Return] setting. For more detailed information about working with the return values, see the User Guide.

This keyword is typically wrapped to some other keyword, such as Run Keyword If, to return based on a condition:

| Run Keyword If ${rc} < 0 Return From Keyword

It is possible to use this keyword to return from a keyword also inside a for loop. That, as well as returning values, is demonstrated by the Find Index keyword in the following somewhat advanced example. Notice that it is often a good idea to move this kind of complicated logic into a library.

| ***** Variables ***** |LIST} = foo baz | | ***** Test Cases ***** | Example | ${index} = Find Index bazLIST} | Should Be Equal ${index} ${1} | ${index} = Find Index non existingLIST} | Should Be Equal ${index} ${-1} | | ***** Keywords ***** | Find Index | [Arguments] ${element}items} | ${index} = Set Variable ${0} | FOR ${item} INitems} | Run Keyword If '${item}' == '${element}' Return From Keyword ${index} | ${index} = Set Variable ${index + 1} | END | Return From Keyword ${-1}

The most common use case, returning based on an expression, can be accomplished directly with Return From Keyword If. See also Run Keyword And Return and Run Keyword And Return If.

Definition at line 2726 of file BuiltIn.py.

◆ return_from_keyword_if()

def robot.libraries.BuiltIn._Control.return_from_keyword_if (   self,
  condition,
return_values 
)

Returns from the enclosing user keyword if condition is true.


NOTE: Robot Framework 5.0 added support for native RETURN statement and for inline IF, and that combination should be used instead of this keyword. For example, Return From Keyword usage in the example below could be replaced with

| IF '${item}' == '${element}' RETURN ${index}

This keyword will eventually be deprecated and removed.


A wrapper for Return From Keyword to return based on the given condition. The condition is evaluated using the same semantics as with Should Be True keyword.

Given the same example as in Return From Keyword, we can rewrite the Find Index keyword as follows:

| ***** Keywords ***** | Find Index | [Arguments] ${element}items} | ${index} = Set Variable ${0} | FOR ${item} INitems} | Return From Keyword If '${item}' == '${element}' ${index} | ${index} = Set Variable ${index + 1} | END | Return From Keyword ${-1}

See also Run Keyword And Return and Run Keyword And Return If.

Definition at line 2768 of file BuiltIn.py.

◆ run_keyword_and_return()

def robot.libraries.BuiltIn._Control.run_keyword_and_return (   self,
  name,
args 
)

Runs the specified keyword and returns from the enclosing user keyword.

    The keyword to execute is defined with ``name`` and ``*args`` exactly
    like with `Run Keyword`. After running the keyword, returns from the
    enclosing user keyword and passes possible return value from the
    executed keyword further. Returning from a keyword has exactly same
    semantics as with `Return From Keyword`.

    Example:
    | `Run Keyword And Return`  | `My Keyword` | arg1 | arg2 |
    | # Above is equivalent to: |
    | ${result} =               | `My Keyword` | arg1 | arg2 |
    | `Return From Keyword`     | ${result}    |      |      |

    Use `Run Keyword And Return If` if you want to run keyword and return
    based on a condition.

Definition at line 2790 of file BuiltIn.py.

◆ run_keyword_and_return_if()

def robot.libraries.BuiltIn._Control.run_keyword_and_return_if (   self,
  condition,
  name,
args 
)

Runs the specified keyword and returns from the enclosing user keyword.

    A wrapper for `Run Keyword And Return` to run and return based on
    the given ``condition``. The condition is evaluated using the same
    semantics as with `Should Be True` keyword.

    Example:
    | `Run Keyword And Return If` | ${rc} > 0 | `My Keyword` | arg1 | arg2 |
    | # Above is equivalent to:   |
    | `Run Keyword If`            | ${rc} > 0 | `Run Keyword And Return` | `My Keyword ` | arg1 | arg2 |

    Use `Return From Keyword If` if you want to return a certain value
    based on a condition.

Definition at line 2813 of file BuiltIn.py.

◆ skip()

def robot.libraries.BuiltIn._Control.skip (   self,
  msg = 'Skipped with Skip keyword.' 
)

Skips the rest of the current test.

    Skips the remaining keywords in the current test and sets the given
    message to the test. If the test has teardown, it will be executed.

Definition at line 2519 of file BuiltIn.py.

◆ skip_if()

def robot.libraries.BuiltIn._Control.skip_if (   self,
  condition,
  msg = None 
)

Skips the rest of the current test if the condition is True.

    Skips the remaining keywords in the current test and sets the given
    message to the test. If ``msg`` is not given, the ``condition`` will
    be used as the message. If the test has teardown, it will be executed.

    If the ``condition`` evaluates to False, does nothing.

Definition at line 2530 of file BuiltIn.py.


The documentation for this class was generated from the following file: