robot.result package
Implements parsing execution results from XML output files.
The main public API of this package consists of the ExecutionResult()
factory method, that returns Result
objects, and of the
ResultVisitor
abstract class, that eases further processing
the results. It is recommended to import these public entry-points via the
robot.api
package like in the example below.
The model objects defined in the robot.result.model
module are also
part of the public API. They are used inside the Result
object,
and they can also be inspected and modified as part of the normal test
execution by using pre-Rebot modifiers and listeners. These model
objects are not exposed via robot.api
, but they can be imported
from robot.result
if needed.
Example
#!/usr/bin/env python
"""Usage: check_test_times.py seconds inpath [outpath]
Reads test execution result from an output XML file and checks that no test
took longer than given amount of seconds to execute.
Optional `outpath` specifies where to write processed results. If not given,
results are written over the original file.
"""
import sys
from robot.api import ExecutionResult, ResultVisitor
from robot.result.model import TestCase
class ExecutionTimeChecker(ResultVisitor):
def __init__(self, max_seconds: float):
self.max_milliseconds = max_seconds * 1000
def visit_test(self, test: TestCase):
if test.status == 'PASS' and test.elapsedtime > self.max_milliseconds:
test.status = 'FAIL'
test.message = 'Test execution took too long.'
def check_tests(seconds, inpath, outpath=None):
result = ExecutionResult(inpath)
result.visit(ExecutionTimeChecker(float(seconds)))
result.save(outpath)
if __name__ == '__main__':
try:
check_tests(*sys.argv[1:])
except TypeError:
print(__doc__)
Submodules
robot.result.configurer module
- class robot.result.configurer.SuiteConfigurer(remove_keywords=None, log_level=None, start_time=None, end_time=None, **base_config)[source]
Bases:
SuiteConfigurer
Result suite configured.
Calls suite’s
remove_keywords()
andfilter_messages()
methods and sets its start and end time based on the given named parameters.base_config
is forwarded torobot.model.SuiteConfigurer
that will do further configuration based on them.
robot.result.executionerrors module
robot.result.executionresult module
- class robot.result.executionresult.Result(source=None, root_suite=None, errors=None, rpa=None)[source]
Bases:
object
Test execution results.
Can be created based on XML output files using the
ExecutionResult()
factory method. Also returned by therobot.running.TestSuite.run
method.- source
Path to the XML file where results are read from.
- errors
Execution errors as an
ExecutionErrors
object.
- property statistics
Test execution statistics.
Statistics are an instance of
Statistics
that is created based on the containedsuite
and possibleconfiguration
.Statistics are created every time this property is accessed. Saving them to a variable is thus often a good idea to avoid re-creating them unnecessarily:
from robot.api import ExecutionResult result = ExecutionResult('output.xml') result.configure(stat_config={'suite_stat_level': 2, 'tag_stat_combine': 'tagANDanother'}) stats = result.statistics print(stats.total.failed) print(stats.total.passed) print(stats.tags.combined[0].total)
- property return_code
Return code (integer) of test execution.
By default returns the number of failed tests (max 250), but can be
configured
to always return 0.
- configure(status_rc=True, suite_config=None, stat_config=None)[source]
Configures the result object and objects it contains.
- Parameters:
status_rc – If set to
False
,return_code
always returns 0.suite_config – A dictionary of configuration options passed to
configure()
method of the containedsuite
.stat_config – A dictionary of configuration options used when creating
statistics
.
- save(target=None, legacy_output=False)[source]
Save results as XML or JSON file.
- Parameters:
target – Target where to save results to. Can be a path (
pathlib.Path
orstr
) or an open file object. If omitted, uses thesource
which overwrites the original file.legacy_output – Save result in Robot Framework 6.x compatible format. New in Robot Framework 7.0.
File type is got based on the
target
. The type is JSON if thetarget
is a path that has a.json
suffix or if it is an open file that has aname
attribute with a.json
suffix. Otherwise, the type is XML.Notice that saved JSON files only contain suite information, no statics or errors like XML files. This is likely to change in the future so that JSON files get a new root object with the current suite as a child and statics and errors as additional children. Robot Framework’s own functions and methods accepting JSON results will continue to work also with JSON files containing only a suite.
- visit(visitor)[source]
An entry point to visit the whole result object.
- Parameters:
visitor – An instance of
ResultVisitor
.
Visitors can gather information, modify results, etc. See
result
package for a simple usage example.Notice that it is also possible to call
result.suite.visit
if there is no need to visit the containedstatistics
orerrors
.
robot.result.flattenkeywordmatcher module
- class robot.result.flattenkeywordmatcher.FlattenByTags(flatten)[source]
Bases:
SuiteVisitor
robot.result.keywordremover module
- class robot.result.keywordremover.KeywordRemover[source]
Bases:
SuiteVisitor
,ABC
- message = 'Content removed using the --remove-keywords option.'
- class robot.result.keywordremover.AllKeywordsRemover[source]
Bases:
KeywordRemover
- start_body_item(item)[source]
Called, by default, when keywords, messages or control structures start.
More specific
start_keyword()
,start_message()
, :meth:`start_for, etc. can be implemented to visit only keywords, messages or specific control structures.Can return explicit
False
to stop visiting. Default implementation does nothing.
- start_if(item)[source]
Called when an IF/ELSE structure starts.
By default, calls
start_body_item()
which, by default, does nothing.Can return explicit
False
to stop visiting.
- start_if_branch(item)[source]
Called when an IF/ELSE branch starts.
By default, calls
start_body_item()
which, by default, does nothing.Can return explicit
False
to stop visiting.
- start_try(item)[source]
Called when a TRY/EXCEPT structure starts.
By default, calls
start_body_item()
which, by default, does nothing.Can return explicit
False
to stop visiting.
- start_try_branch(item)[source]
Called when TRY, EXCEPT, ELSE or FINALLY branches start.
By default, calls
start_body_item()
which, by default, does nothing.Can return explicit
False
to stop visiting.
- class robot.result.keywordremover.PassedKeywordRemover[source]
Bases:
KeywordRemover
- start_suite(suite)[source]
Called when a suite starts. Default implementation does nothing.
Can return explicit
False
to stop visiting.
- class robot.result.keywordremover.ByNameKeywordRemover(pattern)[source]
Bases:
KeywordRemover
- class robot.result.keywordremover.ByTagKeywordRemover(pattern)[source]
Bases:
KeywordRemover
- class robot.result.keywordremover.LoopItemsRemover[source]
Bases:
KeywordRemover
,ABC
- message = '{count} passing item{s} removed using the --remove-keywords option.'
- class robot.result.keywordremover.ForLoopItemsRemover[source]
Bases:
LoopItemsRemover
- class robot.result.keywordremover.WhileLoopItemsRemover[source]
Bases:
LoopItemsRemover
- class robot.result.keywordremover.WaitUntilKeywordSucceedsRemover[source]
Bases:
KeywordRemover
- message = '{count} failing item{s} removed using the --remove-keywords option.'
- class robot.result.keywordremover.WarningAndErrorFinder[source]
Bases:
SuiteVisitor
- start_suite(suite)[source]
Called when a suite starts. Default implementation does nothing.
Can return explicit
False
to stop visiting.
- start_test(test)[source]
Called when a test starts. Default implementation does nothing.
Can return explicit
False
to stop visiting.
robot.result.merger module
- class robot.result.merger.Merger(result, rpa=False)[source]
Bases:
SuiteVisitor
robot.result.messagefilter module
- class robot.result.messagefilter.MessageFilter(log_level=None)[source]
Bases:
SuiteVisitor
robot.result.model module
Module implementing result related model objects.
During test execution these objects are created internally by various runners. At that time they can be inspected and modified by listeners.
When results are parsed from XML output files after execution to be able to
create logs and reports, these objects are created by the
ExecutionResult()
factory method.
At that point they can be inspected and modified by pre-Rebot modifiers.
The ExecutionResult()
factory method can also be used
by custom scripts and tools. In such usage it is often easiest to inspect and
modify these objects using the visitor interface
.
If classes defined here are needed, for example, as type hints, they can
be imported via the robot.running
module.
- class robot.result.model.Body(parent: TestSuite | TestCase | UserKeyword | For | ForIteration | If | IfBranch | Try | TryBranch | While | WhileIteration | Keyword | Var | Return | Continue | Break | Error | None = None, items: Iterable[BodyItem | DataDict] = ())[source]
Bases:
BaseBody
[Keyword, For, While, If, Try, Var, Return, Continue, Break, Message, Error]
- class robot.result.model.Branches(branch_class: Type[IT], parent: TestSuite | TestCase | UserKeyword | For | ForIteration | If | IfBranch | Try | TryBranch | While | WhileIteration | Keyword | Var | Return | Continue | Break | Error | None = None, items: Iterable[IT | DataDict] = ())[source]
Bases:
BaseBranches
[Keyword, For, While, If, Try, Var, Return, Continue, Break, Message, Error,IT
]
- class robot.result.model.Iterations(iteration_class: Type[FW], parent: TestSuite | TestCase | UserKeyword | For | ForIteration | If | IfBranch | Try | TryBranch | While | WhileIteration | Keyword | Var | Return | Continue | Break | Error | None = None, items: Iterable[FW | DataDict] = ())[source]
Bases:
BaseIterations
[Keyword, For, While, If, Try, Var, Return, Continue, Break, Message, Error,FW
]
- class robot.result.model.Message(message: str = '', level: Literal['TRACE', 'DEBUG', 'INFO', 'WARN', 'ERROR', 'FAIL', 'SKIP'] = 'INFO', html: bool = False, timestamp: datetime | str | None = None, parent: BodyItem | None = None)[source]
Bases:
Message
- class robot.result.model.StatusMixin[source]
Bases:
object
- PASS = 'PASS'
- FAIL = 'FAIL'
- SKIP = 'SKIP'
- NOT_RUN = 'NOT RUN'
- NOT_SET = 'NOT SET'
- status: Literal['PASS', 'FAIL', 'SKIP', 'NOT RUN', 'NOT SET']
- property start_time: datetime | None
Execution start time as a
datetime
or as aNone
if not set.If start time is not set, it is calculated based
end_time
andelapsed_time
if possible.Can be set either directly as a
datetime
or as a string in ISO 8601 format.New in Robot Framework 6.1. Heavily enhanced in Robot Framework 7.0.
- property end_time: datetime | None
Execution end time as a
datetime
or as aNone
if not set.If end time is not set, it is calculated based
start_time
andelapsed_time
if possible.Can be set either directly as a
datetime
or as a string in ISO 8601 format.New in Robot Framework 6.1. Heavily enhanced in Robot Framework 7.0.
- property elapsed_time: timedelta
Total execution time as a
timedelta
.If not set, calculated based on
start_time
andend_time
if possible. If that fails, calculated based on the elapsed time of child items.Can be set either directly as a
timedelta
or as an integer or a float representing seconds.New in Robot Framework 6.1. Heavily enhanced in Robot Framework 7.0.
- property starttime: str | None
Execution start time as a string or as a
None
if not set.The string format is
%Y%m%d %H:%M:%S.%f
.Considered deprecated starting from Robot Framework 7.0.
start_time
should be used instead.
- property endtime: str | None
Execution end time as a string or as a
None
if not set.The string format is
%Y%m%d %H:%M:%S.%f
.Considered deprecated starting from Robot Framework 7.0.
end_time
should be used instead.
- property elapsedtime: int
Total execution time in milliseconds.
Considered deprecated starting from Robot Framework 7.0.
elapsed_time
should be used instead.
- property skipped: bool
True
whenstatus
is ‘SKIP’,False
otherwise.Setting to
False
value is ambiguous and raises an exception.
- class robot.result.model.ForIteration(assign: Mapping[str, str] | None = None, status: str = 'FAIL', message: str = '', start_time: datetime | str | None = None, end_time: datetime | str | None = None, elapsed_time: timedelta | int | float | None = None, parent: TestSuite | TestCase | Keyword | For | ForIteration | If | IfBranch | Try | TryBranch | While | WhileIteration | None = None)[source]
Bases:
ForIteration
,StatusMixin
,DeprecatedAttributesMixin
- status: Literal['PASS', 'FAIL', 'SKIP', 'NOT RUN', 'NOT SET']
- message
- to_dict() Dict[str, Any] [source]
Serialize this object into a dictionary.
The object can be later restored by using the
from_dict()
method.With
robot.running
model objects new in Robot Framework 6.1, withrobot.result
new in Robot Framework 7.0.
- assign
- class robot.result.model.For(assign: Sequence[str] = (), flavor: Literal['IN', 'IN RANGE', 'IN ENUMERATE', 'IN ZIP'] = 'IN', values: Sequence[str] = (), start: str | None = None, mode: str | None = None, fill: str | None = None, status: str = 'FAIL', message: str = '', start_time: datetime | str | None = None, end_time: datetime | str | None = None, elapsed_time: timedelta | int | float | None = None, parent: TestSuite | TestCase | Keyword | For | ForIteration | If | IfBranch | Try | TryBranch | While | WhileIteration | None = None)[source]
Bases:
For
,StatusMixin
,DeprecatedAttributesMixin
- iteration_class
alias of
ForIteration
- iterations_class
alias of
Iterations
[ForIteration
]
- status: Literal['PASS', 'FAIL', 'SKIP', 'NOT RUN', 'NOT SET']
- message
- body
- class robot.result.model.WhileIteration(status: str = 'FAIL', message: str = '', start_time: datetime | str | None = None, end_time: datetime | str | None = None, elapsed_time: timedelta | int | float | None = None, parent: TestSuite | TestCase | Keyword | For | ForIteration | If | IfBranch | Try | TryBranch | While | WhileIteration | None = None)[source]
Bases:
WhileIteration
,StatusMixin
,DeprecatedAttributesMixin
- status: Literal['PASS', 'FAIL', 'SKIP', 'NOT RUN', 'NOT SET']
- message
- class robot.result.model.While(condition: str | None = None, limit: str | None = None, on_limit: str | None = None, on_limit_message: str | None = None, status: str = 'FAIL', message: str = '', start_time: datetime | str | None = None, end_time: datetime | str | None = None, elapsed_time: timedelta | int | float | None = None, parent: TestSuite | TestCase | Keyword | For | ForIteration | If | IfBranch | Try | TryBranch | While | WhileIteration | None = None)[source]
Bases:
While
,StatusMixin
,DeprecatedAttributesMixin
- iteration_class
alias of
WhileIteration
- iterations_class
alias of
Iterations
[WhileIteration
]
- status: Literal['PASS', 'FAIL', 'SKIP', 'NOT RUN', 'NOT SET']
- message
- body
- class robot.result.model.IfBranch(type: str = 'IF', condition: str | None = None, status: str = 'FAIL', message: str = '', start_time: datetime | str | None = None, end_time: datetime | str | None = None, elapsed_time: timedelta | int | float | None = None, parent: TestSuite | TestCase | Keyword | For | ForIteration | If | IfBranch | Try | TryBranch | While | WhileIteration | None = None)[source]
Bases:
IfBranch
,StatusMixin
,DeprecatedAttributesMixin
- status: Literal['PASS', 'FAIL', 'SKIP', 'NOT RUN', 'NOT SET']
- message
- class robot.result.model.If(status: str = 'FAIL', message: str = '', start_time: datetime | str | None = None, end_time: datetime | str | None = None, elapsed_time: timedelta | int | float | None = None, parent: TestSuite | TestCase | Keyword | For | ForIteration | If | IfBranch | Try | TryBranch | While | WhileIteration | None = None)[source]
Bases:
If
,StatusMixin
,DeprecatedAttributesMixin
- status: Literal['PASS', 'FAIL', 'SKIP', 'NOT RUN', 'NOT SET']
- message
- class robot.result.model.TryBranch(type: str = 'TRY', patterns: Sequence[str] = (), pattern_type: str | None = None, assign: str | None = None, status: str = 'FAIL', message: str = '', start_time: datetime | str | None = None, end_time: datetime | str | None = None, elapsed_time: timedelta | int | float | None = None, parent: TestSuite | TestCase | Keyword | For | ForIteration | If | IfBranch | Try | TryBranch | While | WhileIteration | None = None)[source]
Bases:
TryBranch
,StatusMixin
,DeprecatedAttributesMixin
- status: Literal['PASS', 'FAIL', 'SKIP', 'NOT RUN', 'NOT SET']
- message
- class robot.result.model.Try(status: str = 'FAIL', message: str = '', start_time: datetime | str | None = None, end_time: datetime | str | None = None, elapsed_time: timedelta | int | float | None = None, parent: TestSuite | TestCase | Keyword | For | ForIteration | If | IfBranch | Try | TryBranch | While | WhileIteration | None = None)[source]
Bases:
Try
,StatusMixin
,DeprecatedAttributesMixin
- status: Literal['PASS', 'FAIL', 'SKIP', 'NOT RUN', 'NOT SET']
- message
- class robot.result.model.Var(name: str = '', value: str | Sequence[str] = (), scope: str | None = None, separator: str | None = None, status: str = 'FAIL', message: str = '', start_time: datetime | str | None = None, end_time: datetime | str | None = None, elapsed_time: timedelta | int | float | None = None, parent: TestSuite | TestCase | Keyword | For | ForIteration | If | IfBranch | Try | TryBranch | While | WhileIteration | None = None)[source]
Bases:
Var
,StatusMixin
,DeprecatedAttributesMixin
- status: Literal['PASS', 'FAIL', 'SKIP', 'NOT RUN', 'NOT SET']
- message
- class robot.result.model.Return(values: Sequence[str] = (), status: str = 'FAIL', message: str = '', start_time: datetime | str | None = None, end_time: datetime | str | None = None, elapsed_time: timedelta | int | float | None = None, parent: TestSuite | TestCase | Keyword | For | ForIteration | If | IfBranch | Try | TryBranch | While | WhileIteration | None = None)[source]
Bases:
Return
,StatusMixin
,DeprecatedAttributesMixin
- status: Literal['PASS', 'FAIL', 'SKIP', 'NOT RUN', 'NOT SET']
- message
- class robot.result.model.Continue(status: str = 'FAIL', message: str = '', start_time: datetime | str | None = None, end_time: datetime | str | None = None, elapsed_time: timedelta | int | float | None = None, parent: TestSuite | TestCase | Keyword | For | ForIteration | If | IfBranch | Try | TryBranch | While | WhileIteration | None = None)[source]
Bases:
Continue
,StatusMixin
,DeprecatedAttributesMixin
- status: Literal['PASS', 'FAIL', 'SKIP', 'NOT RUN', 'NOT SET']
- message
- class robot.result.model.Break(status: str = 'FAIL', message: str = '', start_time: datetime | str | None = None, end_time: datetime | str | None = None, elapsed_time: timedelta | int | float | None = None, parent: TestSuite | TestCase | Keyword | For | ForIteration | If | IfBranch | Try | TryBranch | While | WhileIteration | None = None)[source]
Bases:
Break
,StatusMixin
,DeprecatedAttributesMixin
- status: Literal['PASS', 'FAIL', 'SKIP', 'NOT RUN', 'NOT SET']
- message
- class robot.result.model.Error(values: Sequence[str] = (), status: str = 'FAIL', message: str = '', start_time: datetime | str | None = None, end_time: datetime | str | None = None, elapsed_time: timedelta | int | float | None = None, parent: TestSuite | TestCase | Keyword | For | ForIteration | If | IfBranch | Try | TryBranch | While | WhileIteration | None = None)[source]
Bases:
Error
,StatusMixin
,DeprecatedAttributesMixin
- status: Literal['PASS', 'FAIL', 'SKIP', 'NOT RUN', 'NOT SET']
- message
- class robot.result.model.Keyword(name: str | None = '', owner: str | None = None, source_name: str | None = None, doc: str = '', args: Sequence[str] = (), assign: Sequence[str] = (), tags: Sequence[str] = (), timeout: str | None = None, type: str = 'KEYWORD', status: str = 'FAIL', message: str = '', start_time: datetime | str | None = None, end_time: datetime | str | None = None, elapsed_time: timedelta | int | float | None = None, parent: TestSuite | TestCase | Keyword | For | ForIteration | If | IfBranch | Try | TryBranch | While | WhileIteration | None = None)[source]
Bases:
Keyword
,StatusMixin
Represents an executed library or user keyword.
- owner
Name of the library or resource containing this keyword.
- source_name
Original name of keyword with embedded arguments.
- doc
- timeout
- status: Literal['PASS', 'FAIL', 'SKIP', 'NOT RUN', 'NOT SET']
- message
- body
Possible keyword body as a
Body
object.Body can consist of child keywords, messages, and control structures such as IF/ELSE. Library keywords typically have an empty body.
- property messages: list[Message]
Keyword’s messages.
Starting from Robot Framework 4.0 this is a list generated from messages in
body
.
- property full_name: str | None
Keyword name in format
owner.name
.Just
name
ifowner
is not set. In practice this is the case only with user keywords in the suite file.Cannot be set directly. Set
name
andowner
separately instead.Notice that prior to Robot Framework 7.0, the
name
attribute contained the full name and keyword and owner names were inkwname
andlibname
, respectively.
- property kwname: str | None
Deprecated since Robot Framework 7.0. Use
name
instead.
- property sourcename: str
Deprecated since Robot Framework 7.0. Use
source_name
instead.
- property setup: Keyword
Keyword setup as a
Keyword
object.See
teardown
for more information. New in Robot Framework 7.0.
- property has_setup: bool
Check does a keyword have a setup without creating a setup object.
See
has_teardown
for more information. New in Robot Framework 7.0.
- property teardown: Keyword
Keyword teardown as a
Keyword
object.Teardown can be modified by setting attributes directly:
keyword.teardown.name = 'Example' keyword.teardown.args = ('First', 'Second')
Alternatively the
config()
method can be used to set multiple attributes in one call:keyword.teardown.config(name='Example', args=('First', 'Second'))
The easiest way to reset the whole teardown is setting it to
None
. It will automatically recreate the underlyingKeyword
object:keyword.teardown = None
This attribute is a
Keyword
object also when a keyword has no teardown but in that case its truth value isFalse
. If there is a need to just check does a keyword have a teardown, using thehas_teardown
attribute avoids creating theKeyword
object and is thus more memory efficient.New in Robot Framework 4.0. Earlier teardown was accessed like
keyword.keywords.teardown
.has_teardown
is new in Robot Framework 4.1.2.
- property has_teardown: bool
Check does a keyword have a teardown without creating a teardown object.
A difference between using
if kw.has_teardown:
andif kw.teardown:
is that accessing theteardown
attribute creates aKeyword
object representing a teardown even when the keyword actually does not have one. This typically does not matter, but with bigger suite structures having lots of keywords it can have a considerable effect on memory usage.New in Robot Framework 4.1.2.
- class robot.result.model.TestCase(name: str = '', doc: str = '', tags: Sequence[str] = (), timeout: str | None = None, lineno: int | None = None, status: str = 'FAIL', message: str = '', start_time: datetime | str | None = None, end_time: datetime | str | None = None, elapsed_time: timedelta | int | float | None = None, parent: TestSuite | None = None)[source]
Bases:
TestCase
[Keyword
],StatusMixin
Represents results of a single test case.
See the base class for documentation of attributes not documented here.
- status: Literal['PASS', 'FAIL', 'SKIP', 'NOT RUN', 'NOT SET']
- message
- property not_run: bool
True
whenstatus
is ‘NOT RUN’,False
otherwise.Setting to
False
value is ambiguous and raises an exception.
- body
Test body as a
Body
object.
- class robot.result.model.TestSuite(name: str = '', doc: str = '', metadata: Mapping[str, str] | None = None, source: Path | str | None = None, rpa: bool = False, message: str = '', start_time: datetime | str | None = None, end_time: datetime | str | None = None, elapsed_time: timedelta | int | float | None = None, parent: TestSuite | None = None)[source]
Bases:
TestSuite
[Keyword
,TestCase
],StatusMixin
Represents results of a single test suite.
See the base class for documentation of attributes not documented here.
- message
Possible suite setup or teardown error message.
- property passed: bool
True
if no test has failed but some have passed,False
otherwise.
- property failed: bool
True
if any test has failed,False
otherwise.
- property skipped: bool
True
if there are no passed or failed tests,False
otherwise.
- property not_run: bool
True
whenstatus
is ‘NOT RUN’,False
otherwise.Setting to
False
value is ambiguous and raises an exception.
- property status: Literal['PASS', 'SKIP', 'FAIL']
‘PASS’, ‘FAIL’ or ‘SKIP’ depending on test statuses.
If any test has failed, status is ‘FAIL’.
If no test has failed but at least some test has passed, status is ‘PASS’.
If there are no failed or passed tests, status is ‘SKIP’. This covers both the case when all tests have been skipped and when there are no tests.
- property statistics: TotalStatistics
Suite statistics as a
TotalStatistics
object.Recreated every time this property is accessed, so saving the results to a variable and inspecting it is often a good idea:
stats = suite.statistics print(stats.failed) print(stats.total) print(stats.message)
- property full_message: str
Combination of
message
andstat_message
.
- property stat_message: str
String representation of the
statistics
.
- suites
- remove_keywords(how: str)[source]
Remove keywords based on the given condition.
- Parameters:
how – Which approach to use when removing keywords. Either
ALL
,PASSED
,FOR
,WUKS
, orNAME:<pattern>
.
For more information about the possible values see the documentation of the
--removekeywords
command line option.
- filter_messages(log_level: str = 'TRACE')[source]
Remove log messages below the specified
log_level
.
- configure(**options)[source]
A shortcut to configure a suite using one method call.
Can only be used with the root test suite.
- Parameters:
options – Passed to
SuiteConfigurer
that will then set suite attributes, callfilter()
, etc. as needed.
Example:
suite.configure(remove_keywords='PASSED', doc='Smoke test results.')
Not to be confused with
config()
method that suites, tests, and keywords have to make it possible to set multiple attributes in one call.
- to_dict() Dict[str, Any] [source]
Serialize this object into a dictionary.
The object can be later restored by using the
from_dict()
method.With
robot.running
model objects new in Robot Framework 6.1, withrobot.result
new in Robot Framework 7.0.
- to_xml(file: None = None) str [source]
- to_xml(file: TextIO | Path | str) None
Serialize suite into XML.
The format is the same that is used with normal output.xml files, but the
<robot>
root node is omitted and the result contains only the<suite>
structure.The
file
parameter controls what to do with the resulting XML data. It can be:None
(default) to return the data as a string,an open file object where to write the data to, or
a path (
pathlib.Path
or string) to a file where to write the data using UTF-8 encoding.
A serialized suite can be recreated by using the
from_xml()
method.New in Robot Framework 7.0.
- classmethod from_xml(source: str | TextIO | Path) TestSuite [source]
Create suite based on results in XML.
The data is given as the
source
parameter. It can be:a string containing the data directly,
an open file object where to read the data from, or
a path (
pathlib.Path
or string) to a UTF-8 encoded file to read.
Supports both normal output.xml files and files containing only the
<suite>
structure created, for example, with theto_xml()
method. When using normal output.xml files, possible execution errors listed in<errors>
are silently ignored. If that is a problem,ExecutionResult
should be used instead.New in Robot Framework 7.0.
robot.result.modeldeprecation module
- class robot.result.modeldeprecation.DeprecatedAttributesMixin[source]
Bases:
object
- property name
Deprecated.
- property kwname
Deprecated.
- property libname
Deprecated.
- property args
Deprecated.
- property assign
Deprecated.
- property tags
Deprecated.
- property timeout
Deprecated.
- property doc
Deprecated.
robot.result.resultbuilder module
- robot.result.resultbuilder.ExecutionResult(*sources, **options)[source]
Factory method to constructs
Result
objects.- Parameters:
sources – XML or JSON source(s) containing execution results. Can be specified as paths (
pathlib.Path
orstr
), opened file objects, or strings/bytes containing XML/JSON directly.options – Configuration options. Using
merge=True
causes multiple results to be combined so that tests in the latter results replace the ones in the original. Settingrpa
either toTrue
(RPA mode) orFalse
(test automation) sets execution mode explicitly. By default, it is got from processed output files and conflicting modes cause an error. Other options are passed directly to theExecutionResultBuilder
object used internally.
- Returns:
Result
instance.
A source is considered to be JSON in these cases: - It is a path with a
.json
suffix. - It is an open file that has aname
attribute with a.json
suffix. - It is string or bytes starting with{
and ending with}
.This method should be imported by external code via the
robot.api
package. See therobot.result
package for a usage example.
- class robot.result.resultbuilder.ExecutionResultBuilder(source, include_keywords=True, flattened_keywords=None)[source]
Bases:
object
Builds
Result
objects based on output files.Instead of using this builder directly, it is recommended to use the
ExecutionResult()
factory method.- Parameters:
source – Path to the XML output file to build
Result
objects from.include_keywords – Controls whether to include keywords and control structures like FOR and IF in the result or not. They are not needed when generating only a report.
flattened_keywords – List of patterns controlling what keywords and control structures to flatten. See the documentation of the
--flattenkeywords
option for more details.
- class robot.result.resultbuilder.RemoveKeywords[source]
Bases:
SuiteVisitor
robot.result.suiteteardownfailed module
- class robot.result.suiteteardownfailed.SuiteTeardownFailureHandler[source]
Bases:
SuiteVisitor
- class robot.result.suiteteardownfailed.SuiteTeardownFailed(message, skipped=False)[source]
Bases:
SuiteVisitor
robot.result.visitor module
Visitors can be used to easily traverse result structures.
This module contains ResultVisitor
for traversing the whole
Result
object. It extends
SuiteVisitor
that contains visiting logic
for the test suite structure.
- class robot.result.visitor.ResultVisitor[source]
Bases:
SuiteVisitor
Abstract class to conveniently travel
Result
objects.A visitor implementation can be given to the
visit()
method of a result object. This will cause the result object to be traversed and the visitor’svisit_x()
,start_x()
, andend_x()
methods to be called for each suite, test, keyword and message, as well as for errors, statistics, and other information in the result object. See methods below for a full list of available visitor methods.See the
result package level
documentation for more information about handling results and a concrete visitor example. For more information about the visitor algorithm see documentation inrobot.model.visitor
module.
robot.result.xmlelementhandlers module
- class robot.result.xmlelementhandlers.XmlElementHandler(execution_result, root_handler=None)[source]
Bases:
object
- class robot.result.xmlelementhandlers.ElementHandler[source]
Bases:
object
- element_handlers = {'arg': <robot.result.xmlelementhandlers.ArgumentHandler object>, 'arguments': <robot.result.xmlelementhandlers.ArgumentsHandler object>, 'assign': <robot.result.xmlelementhandlers.AssignHandler object>, 'branch': <robot.result.xmlelementhandlers.BranchHandler object>, 'break': <robot.result.xmlelementhandlers.BreakHandler object>, 'continue': <robot.result.xmlelementhandlers.ContinueHandler object>, 'doc': <robot.result.xmlelementhandlers.DocHandler object>, 'error': <robot.result.xmlelementhandlers.ErrorHandler object>, 'errors': <robot.result.xmlelementhandlers.ErrorsHandler object>, 'for': <robot.result.xmlelementhandlers.ForHandler object>, 'if': <robot.result.xmlelementhandlers.IfHandler object>, 'item': <robot.result.xmlelementhandlers.MetadataItemHandler object>, 'iter': <robot.result.xmlelementhandlers.IterationHandler object>, 'kw': <robot.result.xmlelementhandlers.KeywordHandler object>, 'meta': <robot.result.xmlelementhandlers.MetaHandler object>, 'metadata': <robot.result.xmlelementhandlers.MetadataHandler object>, 'msg': <robot.result.xmlelementhandlers.MessageHandler object>, 'pattern': <robot.result.xmlelementhandlers.PatternHandler object>, 'return': <robot.result.xmlelementhandlers.ReturnHandler object>, 'robot': <robot.result.xmlelementhandlers.RobotHandler object>, 'statistics': <robot.result.xmlelementhandlers.StatisticsHandler object>, 'status': <robot.result.xmlelementhandlers.StatusHandler object>, 'suite': <robot.result.xmlelementhandlers.SuiteHandler object>, 'tag': <robot.result.xmlelementhandlers.TagHandler object>, 'tags': <robot.result.xmlelementhandlers.TagsHandler object>, 'test': <robot.result.xmlelementhandlers.TestHandler object>, 'timeout': <robot.result.xmlelementhandlers.TimeoutHandler object>, 'try': <robot.result.xmlelementhandlers.TryHandler object>, 'value': <robot.result.xmlelementhandlers.ValueHandler object>, 'var': <robot.result.xmlelementhandlers.VarHandler object>, 'variable': <robot.result.xmlelementhandlers.VariableHandler object>, 'while': <robot.result.xmlelementhandlers.WhileHandler object>}
- tag = None
- children = frozenset({})
- class robot.result.xmlelementhandlers.RootHandler[source]
Bases:
ElementHandler
- children = frozenset({'robot', 'suite'})
- class robot.result.xmlelementhandlers.RobotHandler[source]
Bases:
ElementHandler
- tag = 'robot'
- children = frozenset({'errors', 'statistics', 'suite'})
- class robot.result.xmlelementhandlers.SuiteHandler[source]
Bases:
ElementHandler
- tag = 'suite'
- children = frozenset({'doc', 'kw', 'meta', 'metadata', 'status', 'suite', 'test'})
- class robot.result.xmlelementhandlers.TestHandler[source]
Bases:
ElementHandler
- tag = 'test'
- children = frozenset({'break', 'continue', 'doc', 'error', 'for', 'if', 'kw', 'msg', 'return', 'status', 'tag', 'tags', 'timeout', 'try', 'variable', 'while'})
- class robot.result.xmlelementhandlers.KeywordHandler[source]
Bases:
ElementHandler
- tag = 'kw'
- children = frozenset({'arg', 'arguments', 'assign', 'break', 'continue', 'doc', 'error', 'for', 'if', 'kw', 'msg', 'return', 'status', 'tag', 'tags', 'timeout', 'try', 'var', 'variable', 'while'})
- class robot.result.xmlelementhandlers.ForHandler[source]
Bases:
ElementHandler
- tag = 'for'
- children = frozenset({'doc', 'iter', 'kw', 'msg', 'status', 'value', 'var'})
- class robot.result.xmlelementhandlers.WhileHandler[source]
Bases:
ElementHandler
- tag = 'while'
- children = frozenset({'doc', 'iter', 'kw', 'msg', 'status'})
- class robot.result.xmlelementhandlers.IterationHandler[source]
Bases:
ElementHandler
- tag = 'iter'
- children = frozenset({'break', 'continue', 'doc', 'error', 'for', 'if', 'kw', 'msg', 'return', 'status', 'try', 'var', 'variable', 'while'})
- class robot.result.xmlelementhandlers.IfHandler[source]
Bases:
ElementHandler
- tag = 'if'
- children = frozenset({'branch', 'doc', 'kw', 'msg', 'status'})
- class robot.result.xmlelementhandlers.BranchHandler[source]
Bases:
ElementHandler
- tag = 'branch'
- children = frozenset({'break', 'continue', 'doc', 'error', 'for', 'if', 'kw', 'msg', 'pattern', 'return', 'status', 'try', 'variable', 'while'})
- class robot.result.xmlelementhandlers.TryHandler[source]
Bases:
ElementHandler
- tag = 'try'
- children = frozenset({'branch', 'doc', 'kw', 'msg', 'status'})
- class robot.result.xmlelementhandlers.PatternHandler[source]
Bases:
ElementHandler
- tag = 'pattern'
- children = frozenset({})
- class robot.result.xmlelementhandlers.VariableHandler[source]
Bases:
ElementHandler
- tag = 'variable'
- children = frozenset({'kw', 'msg', 'status', 'var'})
- class robot.result.xmlelementhandlers.ReturnHandler[source]
Bases:
ElementHandler
- tag = 'return'
- children = frozenset({'kw', 'msg', 'status', 'value'})
- class robot.result.xmlelementhandlers.ContinueHandler[source]
Bases:
ElementHandler
- tag = 'continue'
- children = frozenset({'kw', 'msg', 'status'})
- class robot.result.xmlelementhandlers.BreakHandler[source]
Bases:
ElementHandler
- tag = 'break'
- children = frozenset({'kw', 'msg', 'status'})
- class robot.result.xmlelementhandlers.ErrorHandler[source]
Bases:
ElementHandler
- tag = 'error'
- children = frozenset({'msg', 'status', 'value'})
- class robot.result.xmlelementhandlers.MessageHandler[source]
Bases:
ElementHandler
- tag = 'msg'
- class robot.result.xmlelementhandlers.ErrorMessageHandler[source]
Bases:
MessageHandler
- class robot.result.xmlelementhandlers.StatusHandler(set_status=True)[source]
Bases:
ElementHandler
- tag = 'status'
- class robot.result.xmlelementhandlers.DocHandler[source]
Bases:
ElementHandler
- tag = 'doc'
- class robot.result.xmlelementhandlers.MetadataHandler[source]
Bases:
ElementHandler
- tag = 'metadata'
- children = frozenset({'item'})
- class robot.result.xmlelementhandlers.MetadataItemHandler[source]
Bases:
ElementHandler
- tag = 'item'
- class robot.result.xmlelementhandlers.MetaHandler[source]
Bases:
ElementHandler
- tag = 'meta'
- class robot.result.xmlelementhandlers.TagsHandler[source]
Bases:
ElementHandler
- tag = 'tags'
- children = frozenset({'tag'})
- class robot.result.xmlelementhandlers.TagHandler[source]
Bases:
ElementHandler
- tag = 'tag'
- class robot.result.xmlelementhandlers.TimeoutHandler[source]
Bases:
ElementHandler
- tag = 'timeout'
- class robot.result.xmlelementhandlers.AssignHandler[source]
Bases:
ElementHandler
- tag = 'assign'
- children = frozenset({'var'})
- class robot.result.xmlelementhandlers.VarHandler[source]
Bases:
ElementHandler
- tag = 'var'
- class robot.result.xmlelementhandlers.ArgumentsHandler[source]
Bases:
ElementHandler
- tag = 'arguments'
- children = frozenset({'arg'})
- class robot.result.xmlelementhandlers.ArgumentHandler[source]
Bases:
ElementHandler
- tag = 'arg'
- class robot.result.xmlelementhandlers.ValueHandler[source]
Bases:
ElementHandler
- tag = 'value'
- class robot.result.xmlelementhandlers.ErrorsHandler[source]
Bases:
ElementHandler
- tag = 'errors'