robot package¶
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.tidy
: Module for test data clean-up and format change.
All the functions above can be imported 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 for internal usage and may change without prior notice.
Tip
More public APIs are exposed by the robot.api
package.
-
robot.
run
(*tests, **options)[source]¶ Programmatic entry point for running tests.
Parameters: - tests – Paths to test case files/directories to be executed similarly
as when running the
robot
command on the command line. - options – Options to configure and control execution. Accepted
options are mostly same as normal command line options to the
robot
command. Option names match command line option long names without hyphens so that, for example,--name
becomesname
.
Most options that can be given from the command line work. An exception is that options
--pythonpath
,--argumentfile
,--help
and--version
are not supported.Options that can be given on the command line multiple times can be passed as lists. For example,
include=['tag1', 'tag2']
is equivalent to--include tag1 --include tag2
. If such options are used only once, they can be given also as a single string likeinclude='tag'
.Options that accept no value can be given as Booleans. For example,
dryrun=True
is same as using the--dryrun
option.Options that accept string
NONE
as a special value can also be used with PythonNone
. For example, usinglog=None
is equivalent to--log NONE
.listener
,prerunmodifier
andprerebotmodifier
options allow passing values as Python objects in addition to module names these command line options support. For example,run('tests', listener=MyListener())
.To capture the standard output and error streams, pass an open file or file-like object as special keyword arguments
stdout
andstderr
, respectively.A return code is returned similarly as when running on the command line. Zero means that tests were executed and no critical test failed, values up to 250 denote the number of failed critical tests, and values between 251-255 are for other statuses documented in the Robot Framework User Guide.
Example:
from robot import run run('path/to/tests.robot') run('tests.robot', include=['tag1', 'tag2'], splitlog=True) with open('stdout.txt', 'w') as stdout: run('t1.robot', 't2.robot', name='Example', log=None, stdout=stdout)
Equivalent command line usage:
robot path/to/tests.robot robot --include tag1 --include tag2 --splitlog tests.robot robot --name Example --log NONE t1.robot t2.robot > stdout.txt
- tests – Paths to test case files/directories to be executed similarly
as when running the
-
robot.
run_cli
(arguments=None, exit=True)[source]¶ Command line execution entry point for running tests.
Parameters: - arguments – Command line options and arguments as a list of strings.
Starting from RF 3.1, defaults to
sys.argv[1:]
if not given. - exit – If
True
, callsys.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
run()
function that allows setting options as keyword arguments likename="Example"
and generally has a richer API for programmatic test execution.- arguments – Command line options and arguments as a list of strings.
Starting from RF 3.1, defaults to
-
robot.
rebot
(*outputs, **options)[source]¶ Programmatic entry point for post-processing outputs.
Parameters: - outputs – Paths to Robot Framework output files similarly
as when running the
rebot
command on the command line. - options – Options to configure processing outputs. Accepted
options are mostly same as normal command line options to the
rebot
command. Option names match command line option long names without hyphens so that, for example,--name
becomesname
.
The semantics related to passing options are exactly the same as with the
run()
function. See its documentation for more details.Examples:
from robot import rebot rebot('path/to/output.xml') with open('stdout.txt', 'w') as stdout: rebot('o1.xml', 'o2.xml', name='Example', log=None, stdout=stdout)
Equivalent command line usage:
rebot path/to/output.xml rebot --name Example --log NONE o1.xml o2.xml > stdout.txt
- outputs – Paths to Robot Framework output files similarly
as when running the
-
robot.
rebot_cli
(arguments=None, exit=True)[source]¶ Command line execution entry point for post-processing outputs.
Parameters: - arguments – Command line options and arguments as a list of strings.
Starting from RF 3.1, defaults to
sys.argv[1:]
if not given. - exit – If
True
, callsys.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
rebot()
function that allows setting options as keyword arguments likename="Example"
and generally has a richer API for programmatic Rebot execution.- arguments – Command line options and arguments as a list of strings.
Starting from RF 3.1, defaults to
Subpackages¶
- robot.api package
- robot.conf package
- robot.htmldata package
- robot.libdocpkg package
- Submodules
- robot.libdocpkg.builder module
- robot.libdocpkg.consoleviewer module
- robot.libdocpkg.datatypes module
- robot.libdocpkg.htmlutils module
- robot.libdocpkg.htmlwriter module
- robot.libdocpkg.java9builder module
- robot.libdocpkg.javabuilder module
- robot.libdocpkg.jsonbuilder module
- robot.libdocpkg.jsonwriter module
- robot.libdocpkg.model module
- robot.libdocpkg.output module
- robot.libdocpkg.robotbuilder module
- robot.libdocpkg.specbuilder module
- robot.libdocpkg.writer module
- robot.libdocpkg.xmlwriter module
- robot.libraries package
- Submodules
- robot.libraries.BuiltIn module
- robot.libraries.Collections module
- robot.libraries.DateTime module
- robot.libraries.Dialogs module
- robot.libraries.Easter module
- robot.libraries.OperatingSystem module
- robot.libraries.Process module
- robot.libraries.Remote module
- robot.libraries.Reserved module
- robot.libraries.Screenshot module
- robot.libraries.String module
- robot.libraries.Telnet module
- robot.libraries.XML module
- robot.libraries.dialogs_ipy module
- robot.libraries.dialogs_jy module
- robot.libraries.dialogs_py module
- robot.model package
- Submodules
- robot.model.body module
- robot.model.configurer module
- robot.model.control module
- robot.model.filter module
- robot.model.fixture module
- robot.model.itemlist module
- robot.model.keyword module
- robot.model.message module
- robot.model.metadata module
- robot.model.modelobject module
- robot.model.modifier module
- robot.model.namepatterns module
- robot.model.statistics module
- robot.model.stats module
- robot.model.suitestatistics module
- robot.model.tags module
- robot.model.tagsetter module
- robot.model.tagstatistics module
- robot.model.testcase module
- robot.model.testsuite module
- robot.model.totalstatistics module
- robot.model.visitor module
- robot.output package
- Subpackages
- Submodules
- robot.output.debugfile module
- robot.output.filelogger module
- robot.output.librarylogger module
- robot.output.listenerarguments module
- robot.output.listenermethods module
- robot.output.listeners module
- robot.output.logger module
- robot.output.loggerhelper module
- robot.output.output module
- robot.output.pyloggingconf module
- robot.output.stdoutlogsplitter module
- robot.output.xmllogger module
- robot.parsing package
- robot.reporting package
- Submodules
- robot.reporting.expandkeywordmatcher module
- robot.reporting.jsbuildingcontext module
- robot.reporting.jsexecutionresult module
- robot.reporting.jsmodelbuilders module
- robot.reporting.jswriter module
- robot.reporting.logreportwriters module
- robot.reporting.outputwriter module
- robot.reporting.resultwriter module
- robot.reporting.stringcache module
- robot.reporting.xunitwriter module
- robot.result package
- Example
- Submodules
- robot.result.configurer module
- robot.result.executionerrors module
- robot.result.executionresult module
- robot.result.flattenkeywordmatcher module
- robot.result.keywordremover module
- robot.result.merger module
- robot.result.messagefilter module
- robot.result.model module
- robot.result.modeldeprecation module
- robot.result.resultbuilder module
- robot.result.suiteteardownfailed module
- robot.result.visitor module
- robot.result.xmlelementhandlers module
- robot.running package
- Examples
- Subpackages
- Submodules
- robot.running.bodyrunner module
- robot.running.context module
- robot.running.dynamicmethods module
- robot.running.handlers module
- robot.running.handlerstore module
- robot.running.importer module
- robot.running.librarykeywordrunner module
- robot.running.libraryscopes module
- robot.running.model module
- robot.running.modelcombiner module
- robot.running.namespace module
- robot.running.outputcapture module
- robot.running.randomizer module
- robot.running.runkwregister module
- robot.running.signalhandler module
- robot.running.status module
- robot.running.statusreporter module
- robot.running.suiterunner module
- robot.running.testlibraries module
- robot.running.usererrorhandler module
- robot.running.userkeyword module
- robot.running.userkeywordrunner module
- robot.tidypkg package
- robot.utils package
- Submodules
- robot.utils.application module
- robot.utils.argumentparser module
- robot.utils.asserts module
- robot.utils.charwidth module
- robot.utils.compat module
- robot.utils.compress module
- robot.utils.connectioncache module
- robot.utils.dotdict module
- robot.utils.encoding module
- robot.utils.encodingsniffer module
- robot.utils.error module
- robot.utils.escaping module
- robot.utils.etreewrapper module
- robot.utils.filereader module
- robot.utils.frange module
- robot.utils.htmlformatters module
- robot.utils.importer module
- robot.utils.markuputils module
- robot.utils.markupwriters module
- robot.utils.match module
- robot.utils.misc module
- robot.utils.normalizing module
- robot.utils.platform module
- robot.utils.recommendations module
- robot.utils.restreader module
- robot.utils.robotenv module
- robot.utils.robotinspect module
- robot.utils.robotio module
- robot.utils.robotpath module
- robot.utils.robottime module
- robot.utils.robottypes module
- robot.utils.robottypes2 module
- robot.utils.robottypes3 module
- robot.utils.setter module
- robot.utils.sortable module
- robot.utils.text module
- robot.utils.unic module
- robot.variables package
- Submodules
- robot.variables.assigner module
- robot.variables.evaluation module
- robot.variables.filesetter module
- robot.variables.finders module
- robot.variables.notfound module
- robot.variables.replacer module
- robot.variables.scopes module
- robot.variables.search module
- robot.variables.store module
- robot.variables.tablesetter module
- robot.variables.variables module
Submodules¶
robot.errors module¶
Exceptions and return codes used internally.
External libraries should not used exceptions defined here.
-
exception
robot.errors.
RobotError
(message='', details='')[source]¶ Bases:
exceptions.Exception
Base class for Robot Framework errors.
Do not raise this method but use more specific errors instead.
-
message
¶
-
args
¶
-
-
exception
robot.errors.
FrameworkError
(message='', details='')[source]¶ Bases:
robot.errors.RobotError
Can be used when the core framework goes to unexpected state.
It is good to explicitly raise a FrameworkError if some framework component is used incorrectly. This is pretty much same as ‘Internal Error’ and should of course never happen.
-
args
¶
-
message
¶
-
-
exception
robot.errors.
DataError
(message='', details='')[source]¶ Bases:
robot.errors.RobotError
Used when the provided test data is invalid.
DataErrors are not caught by keywords that run other keywords (e.g. Run Keyword And Expect Error).
-
args
¶
-
message
¶
-
-
exception
robot.errors.
VariableError
(message='', details='')[source]¶ Bases:
robot.errors.DataError
Used when variable does not exist.
VariableErrors are caught by keywords that run other keywords (e.g. Run Keyword And Expect Error).
-
args
¶
-
message
¶
-
-
exception
robot.errors.
KeywordError
(message='', details='')[source]¶ Bases:
robot.errors.DataError
Used when no keyword is found or there is more than one match.
KeywordErrors are caught by keywords that run other keywords (e.g. Run Keyword And Expect Error).
-
args
¶
-
message
¶
-
-
exception
robot.errors.
TimeoutError
(message='', test_timeout=True)[source]¶ Bases:
robot.errors.RobotError
Used when a test or keyword timeout occurs.
This exception is handled specially so that execution of the current test is always stopped immediately and it is not caught by keywords executing other keywords (e.g. Run Keyword And Expect Error).
-
keyword_timeout
¶
-
args
¶
-
message
¶
-
-
exception
robot.errors.
Information
(message='', details='')[source]¶ Bases:
robot.errors.RobotError
Used by argument parser with –help or –version.
-
args
¶
-
message
¶
-
-
exception
robot.errors.
ExecutionStatus
(message, test_timeout=False, keyword_timeout=False, syntax=False, exit=False, continue_on_failure=False, skip=False, return_value=None)[source]¶ Bases:
robot.errors.RobotError
Base class for exceptions communicating status in test execution.
-
timeout
¶
-
dont_continue
¶
-
continue_on_failure
¶
-
status
¶
-
args
¶
-
message
¶
-
-
exception
robot.errors.
ExecutionFailed
(message, test_timeout=False, keyword_timeout=False, syntax=False, exit=False, continue_on_failure=False, skip=False, return_value=None)[source]¶ Bases:
robot.errors.ExecutionStatus
Used for communicating failures in test execution.
-
args
¶
-
can_continue
(context, templated=False)¶
-
continue_on_failure
¶
-
dont_continue
¶
-
get_errors
()¶
-
message
¶
-
status
¶
-
timeout
¶
-
-
exception
robot.errors.
HandlerExecutionFailed
(details)[source]¶ Bases:
robot.errors.ExecutionFailed
-
args
¶
-
can_continue
(context, templated=False)¶
-
continue_on_failure
¶
-
dont_continue
¶
-
get_errors
()¶
-
message
¶
-
status
¶
-
timeout
¶
-
-
exception
robot.errors.
ExecutionFailures
(errors, message=None)[source]¶ Bases:
robot.errors.ExecutionFailed
-
args
¶
-
can_continue
(context, templated=False)¶
-
continue_on_failure
¶
-
dont_continue
¶
-
message
¶
-
status
¶
-
timeout
¶
-
-
exception
robot.errors.
UserKeywordExecutionFailed
(run_errors=None, teardown_errors=None)[source]¶ Bases:
robot.errors.ExecutionFailures
-
args
¶
-
can_continue
(context, templated=False)¶
-
continue_on_failure
¶
-
dont_continue
¶
-
get_errors
()¶
-
message
¶
-
status
¶
-
timeout
¶
-
-
exception
robot.errors.
ExecutionPassed
(message=None, **kwargs)[source]¶ Bases:
robot.errors.ExecutionStatus
Base class for all exceptions communicating that execution passed.
Should not be raised directly, but more detailed exceptions used instead.
-
earlier_failures
¶
-
status
¶
-
args
¶
-
can_continue
(context, templated=False)¶
-
continue_on_failure
¶
-
dont_continue
¶
-
get_errors
()¶
-
message
¶
-
timeout
¶
-
-
exception
robot.errors.
PassExecution
(message)[source]¶ Bases:
robot.errors.ExecutionPassed
Used by ‘Pass Execution’ keyword.
-
args
¶
-
can_continue
(context, templated=False)¶
-
continue_on_failure
¶
-
dont_continue
¶
-
earlier_failures
¶
-
get_errors
()¶
-
message
¶
-
set_earlier_failures
(failures)¶
-
status
¶
-
timeout
¶
-
-
exception
robot.errors.
ContinueForLoop
(message=None, **kwargs)[source]¶ Bases:
robot.errors.ExecutionPassed
Used by ‘Continue For Loop’ keyword.
-
args
¶
-
can_continue
(context, templated=False)¶
-
continue_on_failure
¶
-
dont_continue
¶
-
earlier_failures
¶
-
get_errors
()¶
-
message
¶
-
set_earlier_failures
(failures)¶
-
status
¶
-
timeout
¶
-
-
exception
robot.errors.
ExitForLoop
(message=None, **kwargs)[source]¶ Bases:
robot.errors.ExecutionPassed
Used by ‘Exit For Loop’ keyword.
-
args
¶
-
can_continue
(context, templated=False)¶
-
continue_on_failure
¶
-
dont_continue
¶
-
earlier_failures
¶
-
get_errors
()¶
-
message
¶
-
set_earlier_failures
(failures)¶
-
status
¶
-
timeout
¶
-
-
exception
robot.errors.
ReturnFromKeyword
(return_value=None, failures=None)[source]¶ Bases:
robot.errors.ExecutionPassed
Used by ‘Return From Keyword’ keyword.
-
args
¶
-
can_continue
(context, templated=False)¶
-
continue_on_failure
¶
-
dont_continue
¶
-
earlier_failures
¶
-
get_errors
()¶
-
message
¶
-
set_earlier_failures
(failures)¶
-
status
¶
-
timeout
¶
-
-
exception
robot.errors.
RemoteError
(message='', details='', fatal=False, continuable=False)[source]¶ Bases:
robot.errors.RobotError
Used by Remote library to report remote errors.
-
args
¶
-
message
¶
-
robot.jarrunner module¶
robot.libdoc module¶
Module implementing the command line entry point for the Libdoc tool.
This module can be executed from the command line using the following approaches:
python -m robot.libdoc
python path/to/robot/libdoc.py
Instead of python
it is possible to use also other Python interpreters.
This module also provides libdoc()
and libdoc_cli()
functions
that can be used programmatically. Other code is for internal usage.
Libdoc itself is implemented in the libdocpkg
package.
-
class
robot.libdoc.
LibDoc
[source]¶ Bases:
robot.utils.application.Application
-
main
(args, name='', version='', format=None, docformat=None, specdocformat=None, quiet=False)[source]¶
-
console
(msg)¶
-
execute
(*arguments, **options)¶
-
execute_cli
(cli_arguments, exit=True)¶
-
parse_arguments
(cli_args)¶ Public interface for parsing command line arguments.
Parameters: cli_args – Command line arguments as a list Returns: options (dict), arguments (list) Raises: Information
when –help or –version usedRaises: DataError
when parsing fails
-
-
robot.libdoc.
libdoc_cli
(arguments=None, exit=True)[source]¶ Executes Libdoc similarly as from the command line.
Parameters: - arguments – Command line options and arguments as a list of strings.
Starting from RF 4.0, defaults to
sys.argv[1:]
if not given. - exit – If
True
, callsys.exit
automatically. New in RF 4.0.
The
libdoc()
function may work better in programmatic usage.Example:
from robot.libdoc import libdoc_cli libdoc_cli(['--version', '1.0', 'MyLibrary.py', 'MyLibrary.html'])
- arguments – Command line options and arguments as a list of strings.
Starting from RF 4.0, defaults to
-
robot.libdoc.
libdoc
(library_or_resource, outfile, name='', version='', format=None, docformat=None, specdocformat=None, quiet=False)[source]¶ Executes Libdoc.
Parameters: - library_or_resource – Name or path of the library or resource file to be documented.
- outfile – Path path to the file where to write outputs.
- name – Custom name to give to the documented library or resource.
- version – Version to give to the documented library or resource.
- format – Specifies whether to generate HTML, XML or JSON output.
If this options is not used, the format is got from the extension of
the output file. Possible values are
'HTML'
,'XML'
,'JSON'
and'LIBSPEC'
. - docformat – Documentation source format. Possible values are
'ROBOT'
,'reST'
,'HTML'
and'TEXT'
. The default value can be specified in library source code and the initial default is'ROBOT'
. - specdocformat – Specifies whether the keyword documentation in spec
files is converted to HTML regardless of the original documentation
format. Possible values are
'HTML'
(convert to HTML) and'RAW'
(use original format). The default depends on the output format. New in Robot Framework 4.0. - quiet – When true, the path of the generated output file is not printed the console. New in Robot Framework 4.0.
Arguments have same semantics as Libdoc command line options with same names. Run
libdoc --help
or consult the Libdoc section in the Robot Framework User Guide for more details.Example:
from robot.libdoc import libdoc libdoc('MyLibrary.py', 'MyLibrary.html', version='1.0')
robot.pythonpathsetter module¶
Module that adds directories needed by Robot to sys.path when imported.
robot.rebot module¶
Module implementing the command line entry point for post-processing outputs.
This module can be executed from the command line using the following approaches:
python -m robot.rebot
python path/to/robot/rebot.py
Instead of python
it is possible to use also other Python interpreters.
This module is also used by the installed rebot
start-up script.
This module also provides rebot()
and rebot_cli()
functions
that can be used programmatically. Other code is for internal usage.
-
class
robot.rebot.
Rebot
[source]¶ Bases:
robot.run.RobotFramework
-
console
(msg)¶
-
execute
(*arguments, **options)¶
-
execute_cli
(cli_arguments, exit=True)¶
-
parse_arguments
(cli_args)¶ Public interface for parsing command line arguments.
Parameters: cli_args – Command line arguments as a list Returns: options (dict), arguments (list) Raises: Information
when –help or –version usedRaises: DataError
when parsing fails
-
validate
(options, arguments)¶
-
-
robot.rebot.
rebot_cli
(arguments=None, exit=True)[source]¶ Command line execution entry point for post-processing outputs.
Parameters: - arguments – Command line options and arguments as a list of strings.
Starting from RF 3.1, defaults to
sys.argv[1:]
if not given. - exit – If
True
, callsys.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
rebot()
function that allows setting options as keyword arguments likename="Example"
and generally has a richer API for programmatic Rebot execution.- arguments – Command line options and arguments as a list of strings.
Starting from RF 3.1, defaults to
-
robot.rebot.
rebot
(*outputs, **options)[source]¶ Programmatic entry point for post-processing outputs.
Parameters: - outputs – Paths to Robot Framework output files similarly
as when running the
rebot
command on the command line. - options – Options to configure processing outputs. Accepted
options are mostly same as normal command line options to the
rebot
command. Option names match command line option long names without hyphens so that, for example,--name
becomesname
.
The semantics related to passing options are exactly the same as with the
run()
function. See its documentation for more details.Examples:
from robot import rebot rebot('path/to/output.xml') with open('stdout.txt', 'w') as stdout: rebot('o1.xml', 'o2.xml', name='Example', log=None, stdout=stdout)
Equivalent command line usage:
rebot path/to/output.xml rebot --name Example --log NONE o1.xml o2.xml > stdout.txt
- outputs – Paths to Robot Framework output files similarly
as when running the
robot.run module¶
Module implementing the command line entry point for executing tests.
This module can be executed from the command line using the following approaches:
python -m robot.run
python path/to/robot/run.py
Instead of python
it is possible to use also other Python interpreters.
This module is also used by the installed robot
start-up script.
This module also provides run()
and run_cli()
functions
that can be used programmatically. Other code is for internal usage.
-
class
robot.run.
RobotFramework
[source]¶ Bases:
robot.utils.application.Application
-
console
(msg)¶
-
execute
(*arguments, **options)¶
-
execute_cli
(cli_arguments, exit=True)¶
-
parse_arguments
(cli_args)¶ Public interface for parsing command line arguments.
Parameters: cli_args – Command line arguments as a list Returns: options (dict), arguments (list) Raises: Information
when –help or –version usedRaises: DataError
when parsing fails
-
-
robot.run.
run_cli
(arguments=None, exit=True)[source]¶ Command line execution entry point for running tests.
Parameters: - arguments – Command line options and arguments as a list of strings.
Starting from RF 3.1, defaults to
sys.argv[1:]
if not given. - exit – If
True
, callsys.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
run()
function that allows setting options as keyword arguments likename="Example"
and generally has a richer API for programmatic test execution.- arguments – Command line options and arguments as a list of strings.
Starting from RF 3.1, defaults to
-
robot.run.
run
(*tests, **options)[source]¶ Programmatic entry point for running tests.
Parameters: - tests – Paths to test case files/directories to be executed similarly
as when running the
robot
command on the command line. - options – Options to configure and control execution. Accepted
options are mostly same as normal command line options to the
robot
command. Option names match command line option long names without hyphens so that, for example,--name
becomesname
.
Most options that can be given from the command line work. An exception is that options
--pythonpath
,--argumentfile
,--help
and--version
are not supported.Options that can be given on the command line multiple times can be passed as lists. For example,
include=['tag1', 'tag2']
is equivalent to--include tag1 --include tag2
. If such options are used only once, they can be given also as a single string likeinclude='tag'
.Options that accept no value can be given as Booleans. For example,
dryrun=True
is same as using the--dryrun
option.Options that accept string
NONE
as a special value can also be used with PythonNone
. For example, usinglog=None
is equivalent to--log NONE
.listener
,prerunmodifier
andprerebotmodifier
options allow passing values as Python objects in addition to module names these command line options support. For example,run('tests', listener=MyListener())
.To capture the standard output and error streams, pass an open file or file-like object as special keyword arguments
stdout
andstderr
, respectively.A return code is returned similarly as when running on the command line. Zero means that tests were executed and no critical test failed, values up to 250 denote the number of failed critical tests, and values between 251-255 are for other statuses documented in the Robot Framework User Guide.
Example:
from robot import run run('path/to/tests.robot') run('tests.robot', include=['tag1', 'tag2'], splitlog=True) with open('stdout.txt', 'w') as stdout: run('t1.robot', 't2.robot', name='Example', log=None, stdout=stdout)
Equivalent command line usage:
robot path/to/tests.robot robot --include tag1 --include tag2 --splitlog tests.robot robot --name Example --log NONE t1.robot t2.robot > stdout.txt
- tests – Paths to test case files/directories to be executed similarly
as when running the
robot.testdoc module¶
Module implementing the command line entry point for the Testdoc tool.
This module can be executed from the command line using the following approaches:
python -m robot.testdoc
python path/to/robot/testdoc.py
Instead of python
it is possible to use also other Python interpreters.
This module also provides testdoc()
and testdoc_cli()
functions
that can be used programmatically. Other code is for internal usage.
-
class
robot.testdoc.
TestDoc
[source]¶ Bases:
robot.utils.application.Application
-
console
(msg)¶
-
execute
(*arguments, **options)¶
-
execute_cli
(cli_arguments, exit=True)¶
-
parse_arguments
(cli_args)¶ Public interface for parsing command line arguments.
Parameters: cli_args – Command line arguments as a list Returns: options (dict), arguments (list) Raises: Information
when –help or –version usedRaises: DataError
when parsing fails
-
validate
(options, arguments)¶
-
-
class
robot.testdoc.
TestdocModelWriter
(output, suite, title=None)[source]¶ Bases:
robot.htmldata.htmlfilewriter.ModelWriter
-
handles
(line)¶
-
-
robot.testdoc.
testdoc_cli
(arguments)[source]¶ Executes Testdoc similarly as from the command line.
Parameters: arguments – command line arguments as a list of strings. For programmatic usage the
testdoc()
function is typically better. It has a better API for that and does not callsys.exit()
like this function.Example:
from robot.testdoc import testdoc_cli testdoc_cli(['--title', 'Test Plan', 'mytests', 'plan.html'])
robot.tidy module¶
Module implementing the command line entry point for the Tidy tool.
This module can be executed from the command line using the following approaches:
python -m robot.tidy
python path/to/robot/tidy.py
Instead of python
it is possible to use also other Python interpreters.
This module also provides Tidy
class and tidy_cli()
function
that can be used programmatically. Other code is for internal usage.
-
class
robot.tidy.
Tidy
(space_count=4, use_pipes=False, line_separator='n')[source]¶ Bases:
robot.parsing.suitestructure.SuiteStructureVisitor
Programmatic API for the Tidy tool.
Arguments accepted when creating an instance have same semantics as Tidy command line options with same names.
-
file
(path, outpath=None)[source]¶ Tidy a file.
Parameters: - path – Path of the input file.
- outpath – Path of the output file. If not given, output is returned.
Use
inplace()
to tidy files in-place.
-
inplace
(*paths)[source]¶ Tidy file(s) in-place.
Parameters: paths – Paths of the files to to process.
-
directory
(path)[source]¶ Tidy a directory.
Parameters: path – Path of the directory to process. All files in a directory, recursively, are processed in-place.
-
end_directory
(structure)¶
-
start_directory
(structure)¶
-
-
class
robot.tidy.
TidyCommandLine
[source]¶ Bases:
robot.utils.application.Application
Command line interface for the Tidy tool.
Typically
tidy_cli()
is a better suited for command line style usage andTidy
for other programmatic usage.-
main
(arguments, recursive=False, inplace=False, usepipes=False, spacecount=4, lineseparator='\n')[source]¶
-
console
(msg)¶
-
execute
(*arguments, **options)¶
-
execute_cli
(cli_arguments, exit=True)¶
-
parse_arguments
(cli_args)¶ Public interface for parsing command line arguments.
Parameters: cli_args – Command line arguments as a list Returns: options (dict), arguments (list) Raises: Information
when –help or –version usedRaises: DataError
when parsing fails
-