Skip to content

robot

The root of the Robot Framework package.

The command line entry points provided by the framework are exposed for programmatic usage as follows:

  • run: Function to run tests.
  • run_cli: Function to run tests with command line argument processing.
  • rebot: Function to post-process outputs.
  • rebot_cli: Function to post-process outputs with command line argument processing.
  • libdoc: Module for library documentation generation.
  • testdoc: Module for test case documentation generation.

All the functions above can be imported directly from the robot root module like from robot import run. Functions and classes provided by the modules need to be imported like from robot.libdoc import libdoc_cli.

The functions and modules listed above are considered stable. Other modules in this package are for internal usage and may change without a prior notice.

Tip

The stable public API is otherwise exposed via the robot.api module.

rebot_cli

rebot_cli(arguments=None, exit=True)

Command line execution entry point for post-processing outputs.

:param arguments: Command line options and arguments as a list of strings. Defaults to sys.argv[1:] if not given. :param exit: If True, call sys.exit with the return code denoting execution status, otherwise just return the rc.

Entry point used when post-processing outputs from the command line, but can also be used by custom scripts. Especially useful if the script itself needs to accept same arguments as accepted by Rebot, because the script can just pass them forward directly along with the possible default values it sets itself.

Example::

1
2
3
from robot import rebot_cli

rebot_cli(['--name', 'Example', '--log', 'NONE', 'o1.xml', 'o2.xml'])

See also the :func:rebot function that allows setting options as keyword arguments like name="Example" and generally has a richer API for programmatic Rebot execution.

Source code in src/robot/rebot.py
def rebot_cli(arguments=None, exit=True):
    """Command line execution entry point for post-processing outputs.

    :param arguments: Command line options and arguments as a list of strings.
        Defaults to ``sys.argv[1:]`` if not given.
    :param exit: If ``True``, call ``sys.exit`` with the return code denoting
        execution status, otherwise just return the rc.

    Entry point used when post-processing outputs from the command line, but
    can also be used by custom scripts. Especially useful if the script itself
    needs to accept same arguments as accepted by Rebot, because the script can
    just pass them forward directly along with the possible default values it
    sets itself.

    Example::

        from robot import rebot_cli

        rebot_cli(['--name', 'Example', '--log', 'NONE', 'o1.xml', 'o2.xml'])

    See also the :func:`rebot` function that allows setting options as keyword
    arguments like ``name="Example"`` and generally has a richer API for
    programmatic Rebot execution.
    """
    if arguments is None:
        arguments = sys.argv[1:]
    return Rebot().execute_cli(arguments, exit=exit)

run_cli

1
2
3
run_cli(
    arguments: list[str] | None = None, exit: bool = True
)

Command line execution entry point for running tests.

Parameters:

Name Type Description Default
arguments list[str] | None

Command line options and arguments as a list of strings. Defaults to sys.argv[1:] if not given.

None
exit bool

If True, call sys.exit with the return code denoting execution status, otherwise just return the rc.

True

Entry point used when running tests from the command line, but can also be used by custom scripts that execute tests. Especially useful if the script itself needs to accept same arguments as accepted by Robot Framework, because the script can just pass them forward directly along with the possible default values it sets itself.

Example:

1
2
3
4
5
6
7
from robot import run_cli

# Run tests and return the return code.
rc = run_cli(['--name', 'Example', 'tests.robot'], exit=False)

# Run tests and exit to the system automatically.
run_cli(['--name', 'Example', 'tests.robot'])

See also the robot.run function that allows setting options as keyword arguments like name="Example" and generally has a richer API for programmatic test execution.

Source code in src/robot/run.py
def run_cli(arguments: 'list[str]|None' = None, exit: bool = True):
    """Command line execution entry point for running tests.

    Parameters:
        arguments: Command line options and arguments as a list of strings.
            Defaults to `sys.argv[1:]` if not given.
        exit: If `True`, call `sys.exit` with the return code denoting
            execution status, otherwise just return the rc.

    Entry point used when running tests from the command line, but can also
    be used by custom scripts that execute tests. Especially useful if the
    script itself needs to accept same arguments as accepted by Robot Framework,
    because the script can just pass them forward directly along with the
    possible default values it sets itself.

    Example:

        from robot import run_cli

        # Run tests and return the return code.
        rc = run_cli(['--name', 'Example', 'tests.robot'], exit=False)

        # Run tests and exit to the system automatically.
        run_cli(['--name', 'Example', 'tests.robot'])

    See also the [robot.run][robot.run.run] function that allows setting options as keyword
    arguments like `name="Example"` and generally has a richer API for
    programmatic test execution.
    """
    if arguments is None:
        arguments = sys.argv[1:]
    return RobotFramework().execute_cli(arguments, exit=exit)