{"id":2265,"library":"robotframework","title":"Robot Framework","description":"Robot Framework is a generic open-source automation framework for acceptance testing, acceptance test-driven development (ATDD), and robotic process automation (RPA). It uses a keyword-driven approach, allowing for easy-to-read test cases. The project is actively maintained with frequent bug fix releases (e.g., 7.4.x series) and feature releases (e.g., 7.4, 7.3) typically a few times a year. The current version is 7.4.2.","status":"active","version":"7.4.2","language":"en","source_language":"en","source_url":"https://github.com/robotframework/robotframework","tags":["testing","automation","rpa","bdd","acceptance-testing","keyword-driven"],"install":[{"cmd":"pip install robotframework","lang":"bash","label":"Install core framework"}],"dependencies":[],"imports":[{"note":"The `robot.run` function is the standard programmatic entry point for executing Robot Framework tests from Python. `robot.main()` is an older, less flexible approach.","wrong":"import robot; robot.main()","symbol":"robot.run","correct":"from robot import run"},{"note":"The `keyword` decorator for creating custom Python keywords resides specifically in `robot.api.deco`.","wrong":"from robot.api import keyword","symbol":"keyword","correct":"from robot.api.deco import keyword"},{"note":"To access Robot Framework's built-in keywords (e.g., Log, Should Be Equal) from a custom Python library, import `BuiltIn` from `robot.libraries.BuiltIn`.","wrong":"from robot.builtins import BuiltIn","symbol":"BuiltIn","correct":"from robot.libraries.BuiltIn import BuiltIn"}],"quickstart":{"code":"import os\nimport tempfile\nfrom pathlib import Path\nfrom robot import run\n\n# Create a temporary .robot test file\nrobot_content = '''\n*** Settings ***\nLibrary    OperatingSystem\n\n*** Test Cases ***\nMy First Robot Test\n    Log To Console    Hello from Robot Framework!\n    Create File    ${TEMPDIR}${/}robot_test.txt    This is a test file.\n    File Should Exist    ${TEMPDIR}${/}robot_test.txt\n    Remove File    ${TEMPDIR}${/}robot_test.txt\n'''\n\nwith tempfile.TemporaryDirectory() as tmpdir:\n    test_file_path = Path(tmpdir) / 'my_test.robot'\n    test_file_path.write_text(robot_content)\n\n    print(f\"Running Robot Framework test from: {test_file_path}\")\n    # Execute the test programmatically\n    # Setting loglevel to DEBUG for verbose output, can be omitted\n    result = run(test_file_path.as_posix(), loglevel='INFO', outputdir=tmpdir)\n\n    if result == 0:\n        print(\"Robot Framework test ran successfully!\")\n    else:\n        print(f\"Robot Framework test failed with exit code: {result}\")\n\n    print(f\"Output and logs can be found in: {tmpdir}\")\n","lang":"python","description":"This quickstart demonstrates how to programmatically run a Robot Framework test from a Python script. It creates a simple `.robot` file on the fly and then uses `robot.run` to execute it. This is useful for integrating Robot Framework into CI/CD pipelines or other automation scripts. Standard usage often involves running tests directly from the command line using `robot path/to/tests.robot`."},"warnings":[{"fix":"Update `FOR` loops in `.robot` files by removing the leading colon. Ensure your environment uses Python 3.8 or newer. Consult release notes for other changes.","message":"Robot Framework 4.0 introduced significant breaking changes, notably the 'FOR' loop syntax changed from `:FOR` to `FOR`, and Python 2 support was completely dropped. All Robot Framework 4.x and newer versions require Python 3.","severity":"breaking","affected_versions":">=4.0"},{"fix":"Migrate to the external `robotframework-testdoc` tool. Install it via `pip install robotframework-testdoc` and use it instead of the built-in version.","message":"The built-in `Testdoc` tool has been deprecated in Robot Framework 7.4.2 in favor of the external `robotframework-testdoc` tool.","severity":"deprecated","affected_versions":">=7.4.2"},{"fix":"Embrace the keyword-driven syntax for test cases. Use Python primarily for creating custom keywords (libraries) or for programmatic execution/reporting, rather than writing entire test cases in Python scripts.","message":"Robot Framework is primarily driven by its domain-specific language (DSL) in `.robot` files and executed via a command-line interface. It's not a 'pure Python' testing framework like `pytest` or `unittest`. While it has a Python API for extension (custom libraries, listeners), most test logic resides in `.robot` files.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `set PYTHONPATH=<path/to/my/libraries>` before running tests, or specify the library path directly in the `.robot` file using `Library    ./my_libraries/MyLibrary.py`.","message":"When creating custom Python libraries for Robot Framework, their modules must be discoverable. This often means ensuring they are in the `PYTHONPATH` or placed directly under the test suite directory.","severity":"gotcha","affected_versions":"all"},{"fix":"Familiarize yourself with the 'Variables' section of the Robot Framework User Guide. Use `Log Variables` keyword for debugging variable states and explicitly define variable scopes when necessary.","message":"Robot Framework's variable scoping (scalar, list, dictionary, global, suite, test) can be complex and lead to unexpected behavior if not understood.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}