Generic automation framework for acceptance testing and robotic process automation (RPA)
npx @tessl/cli install tessl/pypi-robotframework@7.3.0Robot Framework is a comprehensive automation framework designed for acceptance testing, acceptance test-driven development (ATDD), and robotic process automation (RPA). It features a plain text syntax that makes test creation accessible to both technical and non-technical users, while supporting extensive customization through generic and custom libraries.
pip install robotframeworkMain programmatic APIs:
from robot import run, run_cli, rebot, rebot_cliPublic API classes and functions:
from robot.api import (
TestSuite, TestSuiteBuilder, ResultWriter, ExecutionResult, ResultVisitor,
SuiteVisitor, TypeInfo, Languages, Language
)Library development APIs:
from robot.api import keyword, library, not_keyword
from robot.api import Failure, ContinuableFailure, Error, FatalError, SkipExecution
from robot.api import logger
from robot.api.interfaces import DynamicLibrary, HybridLibrary, ListenerV2, ListenerV3, ParserParsing APIs:
from robot.api.parsing import get_model, get_tokens, Token, ModelVisitor, ModelTransformerfrom robot import run
# Run tests from a directory
result = run('tests/')
# Run specific test files with options
result = run('tests/example.robot', outputdir='results', loglevel='DEBUG')
# Run with custom settings
result = run(
'tests/',
outputdir='results',
report='custom_report.html',
log='custom_log.html',
include=['smoke', 'critical'],
exclude=['slow']
)
print(f"Tests run: {result.return_code}")from robot.api import TestSuite
# Create a test suite
suite = TestSuite('Example Suite')
# Add a test case
test = suite.tests.create('Example Test')
test.keywords.create('Log', args=['Hello, Robot Framework!'])
test.keywords.create('Should Be Equal', args=['${GREETING}', 'Hello'])
# Run the suite
result = suite.run(outputdir='results')from robot.api import ExecutionResult
# Read execution results from XML
result = ExecutionResult('output.xml')
# Access test statistics
print(f"Total tests: {result.suite.test_count}")
print(f"Passed: {result.suite.statistics.passed}")
print(f"Failed: {result.suite.statistics.failed}")
# Iterate through test cases
for test in result.suite.tests:
print(f"Test: {test.name} - Status: {test.status}")Robot Framework follows a layered architecture that separates concerns and enables extensibility:
This architecture enables Robot Framework to support diverse testing scenarios while maintaining simplicity for end users and providing powerful extension points for advanced use cases.
Test execution, result processing, and programmatic control of Robot Framework's main functionality. Includes running tests, processing outputs, and accessing execution results.
def run(*tests, **options): ...
def run_cli(arguments=None, exit=True): ...
def rebot(*outputs, **options): ...
def rebot_cli(arguments=None, exit=True): ...
class TestSuite: ...
class TestSuiteBuilder: ...
class ExecutionResult: ...
class ResultWriter: ...APIs for creating custom test libraries, including decorators, exceptions, logging, and base classes for different library types.
@keyword(name=None, tags=(), types=())
@library(scope=None, version=None, auto_keywords=False)
@not_keyword
class Failure(AssertionError): ...
class Error(RuntimeError): ...
class SkipExecution(Exception): ...
def info(msg: str, html: bool = False, also_console: bool = False): ...
def warn(msg: str, html: bool = False): ...
def error(msg: str, html: bool = False): ...Test data parsing, AST model manipulation, and programmatic access to Robot Framework's internal data structures.
def get_model(source, **options): ...
def get_tokens(source, **options): ...
class Token: ...
class ModelVisitor: ...
class ModelTransformer: ...
class SuiteVisitor: ...Standard test libraries that provide essential keywords for common testing tasks including system operations, data manipulation, and test control flow.
class BuiltIn: ...
class Collections: ...
class String: ...
class OperatingSystem: ...
class Process: ...
class DateTime: ...Settings, language support, type conversion, and variable handling systems for customizing Robot Framework behavior.
class TypeInfo: ...
class Languages: ...
class Language: ...
def contains_variable(string): ...
def is_variable(string): ...
def evaluate_expression(expression, variables): ...Robot Framework includes tools for generating documentation from test libraries and test suites:
def libdoc_cli(arguments=None, exit=True): ...
def libdoc(library_or_resource, outfile, **options): ...Generate HTML documentation for test libraries showing available keywords, their arguments, and documentation.
def testdoc_cli(arguments): ...
def testdoc(*arguments, **options): ...Generate HTML documentation from test suites showing test cases, keywords, and test data structure.
Robot Framework provides three main command line tools:
robot - Execute tests and generate resultsrebot - Post-process existing result fileslibdoc - Generate library documentationThese tools can also be invoked programmatically through their corresponding CLI functions.
Core type definitions used throughout the Robot Framework API:
# Execution types
TestResult = int # Return code: 0 for success, non-zero for failures/errors
# Library interface types
Name = str
Arguments = Sequence[Union[str, Tuple[str], Tuple[str, Any]]]
Documentation = str
Tags = Sequence[str]
TypeHints = Union[Mapping[str, TypeHint], Sequence[TypeHint]]
# Parsing types
Token = Union[str, Tuple[str, str], Tuple[str, str, int, int]]
# Logging types
LOGLEVEL = Literal["TRACE", "DEBUG", "INFO", "WARN", "ERROR"]
# Decorator types
Scope = Literal["GLOBAL", "SUITE", "TEST", "TASK"]
DocFormat = Literal["ROBOT", "HTML", "TEXT", "REST"]