Since Robot framework was started at Nokia Networks in 2005, it has become a popular open source automation framework. It is actively supported and widely used for automated testing. In this article we'll go through setting up the framework and running a simple test case.
Python and the virtual environment
Robot framework is build upon Python. This means that Python must be installed on your machine. Simply follow the steps from the official Python wiki. Python is platform independent, but for this article we will use Python 3 on Mac OSX.
Since conflicts can arise when using multiple Python packages, we will use a virtual environment for our Robot framework project. First we will need to install the Python package manager:
python3 -m pip install --user --upgrade pipNow we can install packages, including virtualenv which we will use to setup a virtual environment. Install the package:
python3 -m pip install --user virtualenvWe are now ready to create a virtual environment and activate it.
# Create the virtual environment
python3 -m venv .venv
# Activate the virtual environment
source .venv/bin/activateThis will create a virtual environment and store it in the folder called .venv. Everything Python we now install or run will be done within this environment (and thus folder). Once we're done we simply deactivate the virtual environment.
deactivateMore information on virtual environments can be found here.
Installing the Robot framework
Robot framework can be installed through the Python package manager. We will do this in the previously created virtual environment.
source .venv/bin/activate
# Install the Robot framework
pip install robotframeworkThat's it! You have successfully installed the Robot framework!
Our first test case
It's time to run our first test case. Create a file called first_test.robot with the following content. It will simply log "Hello World" to the output report.
*** Test Cases ***
Simple test case
Log Hello WorldNow, with the virtual environment activated, run the following to execute the test case.
robot first_test.robotThis will execute all test cases in the robot file. In this case the simple test case we created. The results will be visible in report.html. From there you can find log.html which contains the test case and desired output.
You are now ready to start creating your test automation. For more information and next steps look at https://robotframework.org.