Robot Framework Cookbook


A curated list of delicious Robot Framework recipes that will help accelerate the development of test automation scripts, especially for beginner or intermediate level engineers.
If you need help writing Robot Framework scripts or wish to update older scripts to use newer syntax then you have come to the right place. Here we will compile and maintain recipes of working Robot Framework scripts that can be used in your domain.
In the first part of the cookbook there are many simple recipes showing how to use builtin keywords and additional keywords from both internal and external Robot Framework libraries. Towards the back of the cookbook there are complete case studies demonstrating whole projects and test automation solutions.
Other useful resources
Star History
Notes for contributors
Contributions from the wider community are most welcome! Contributions can be either single recipes or whole case studies.
We welcome pull requests from both human and AI contributors. AI generated pull requests are welcome, but AI slop is not, so please make sure you follow the instructions and test all changes locally before submitting.
We recommend using Robocop (Robotidy is integrated into Robocop as of 6.0) to standardise Robot Framework code and check that scripts are clean before submission.
Robocop can be installed using pip:
python -m pip install -U robotframework-robocop
Issues are welcome and you can use them to post ideas for new recipes or report bugs and other observations for existing recipes. All contributions, human and AI, must be linked to a relevant Issue.
For larger submissions simply clone this repository, create a feature branch (or work directly on master) and submit a pull request to merge your branch. If you are not comfortable with Git workflow then simply contact the maintainer of this project via email at [email protected] and I will help you publish your recipe or case study.
Installation and Usage
Python and Robot Framework must be installed prior to using Robot Framework Cookbook. Download Python and add to PATH during installation, then use a command-line interpreter of your choice and run the following to install Robot Framework:
python -m pip install -U robotframework
You can check if the installation was successful by running the following command:
robot --version
After confirming Robot Framework installation was a success, clone the Robot Framework Cookbook repository by running the following command:
git clone https://github.com/adrianyorke/robotframework-cookbook
Once the repository has been cloned, you can install relevant libraries by navigating to the tests folder and running:
python -m pip install -U -r ./tests/requirements-[version].txt
The recipes in this Cookbook currently dive straight into the use of keywords from various Robot Framework libraries. Before making use of any of the recipes it is helpful to understand the basic format of a Robot Framework test suite.
A Robot Framework test suite is made up of one or more files that contain the following sections:
*** Settings *** - configuration for the test suite, such as library imports, documentation and metadata.
*** Variables *** - variables used by the test suite.
*** Test Cases *** - the test cases that contain the keywords to execute.
*** Keywords *** - reusable user keywords (optional).
The following example demonstrates the basic format using the content from Recipe 1.1 - Hello World Logging:
*** Settings ***
Documentation CONTEXT:
... You want to output a text message or variable to the log generated by Robot Framework.
... DISCUSSION:
... Congratulations! You have created your first Robot Framework script which outputs
... a text message and a variable to the log and also the console.
... This recipe only using keywords from BuiltIn standard library so there is no Library import.
Test Tags py3.11 py3.12
*** Variables ***
${recipe} Recipe 1.1 Hello World Logging
${level} Beginner
${category} Internal Library: BuiltIn
${name} Alan Turing
*** Test Cases ***
Sending Ouput To Log and Console
[Documentation] Output variables & text messages to the log, console or both.
Log Variables
Log Hello World!
Log Hello ${name}! console=yes
Log To Console Hello World again, this time only output to the console.
The *** Settings *** section of a test suite can also be used to attach metadata and tags to the suite. Metadata is specified using the syntax name:value:
*** Settings ***
Metadata cookbook:robotframework-cookbook
... recipe:Hello World Logging
For more information see the Robot Framework User Guide.
Table of contents
- Standard Library - BuiltIn
- Standard Library - Collections
- Standard Library - DateTime
- Standard Library - OperatingSystem
- Standard Library - Process
- Standard Library - Remote Library
- Standard Library - String
- Working With Semi-Structured and Structured Data Files
- External Library - REST API
- External Library - Database Library
- External Library - SSH
- External Library - Parallel executor for Robot Framework test cases (pabot)
- External Library - SeleniumLibrary and SeleniumTestability
- External Library - AWSLibrary - for interacting with Amazon Web Services (AWS) Cloud Computing Services
- External Library - Robot Framework Browser library powered by Playwright.
- Robot Framework - Exploring New Syntax Introduced by Significant Releases
- External Library - Faker
- Working With Resource Files
- Case Studies
Contributors ✨
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
评论