Skip to main content

I'm looking for testing

This chapter will help you to get started with Robot Framework.

Install Python

Install Python Windows

Download and run the Python installer

  1. Select option Add Python 3.X to PATH
  2. (optional) install to a sub-folder on root of your drive (e.g. C:\Python3.X)
  3. Open a command line by
    1. pressing Windows key + R
    2. typing cmd and pressing Enter
python -V

Check Python version

You should see something like this:

Python 3.10.6
info

Check out the official Python Downloads page or the Python Beginner's Guide for more information

Install Robot Framework

Assumptions and other notes
python, python3, pip, pip3

We assume that Python3 and pip are installed.
We use the commands pip and python to install packages or run Python scripts.
Depending on your setup, those commands may be pip3 and python3 or pip and python.

Terminal, Bash and cmd

When we mention the word terminal, we mean both - a linux terminal (e.g. bash) or a windows command line (cmd).

Install globally vs. virtual environments

Python allows you to install modules via pip.
By default, those modules are installed in the global Python environment.

But especially when working on multiple projects, it is more convenient to have a separate Python environment for each project with all the required packages installed (like robotframework or additional libraries like robotframework-seleniumlibrary).
To separate the global Python environment from the project environment, you can use a virtual environment.
We will cover both approaches in the following chapters.

Show info about installed packages

You can type pip show robotframework to get more information about the installed version of Robot Framework and the install location.

Install Robot Framework globally

Open your terminal

pip install robotframework
robot --version

Install Robot Framework

You should see something like

Robot Framework 5.x.y (Python 3.x.y)

Install Robot Framework in a Virtual Environment

We recommend to have a folder on your drive to store your projects, e.g. C:\projects.
Open your terminal

cd C:\projects
mkdir MyProject
cd MyProject
python -m venv .venv
.venv\Scripts\activate.bat
pip install robotframework
robot --version

You should see something like

Robot Framework 5.x.y (Python 3.x.y)

You can type pip show robotframework to get more information about the installed version of Robot Framework and the install location.
The virtual environment can be deactivated by typing venv\Scripts\deactivate.bat.

If you prefer to use PowerShell instead of cmd, you can use the following commands for activating and deactivating the virtual environment:

  • Activate: venv\Scripts\activate.ps1
  • Deactivate: venv\Scripts\deactivate.ps1

Install Robot Framework in Virtual Environment

Other Recommendations

Managing Dependencies with poetry

Poetry is a tool for dependency management and packaging in Python.

It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
You can use it when you start any new project python or robotframework project.

Install poetry by following the official instructions.

Open PowerShell and run the following command:

(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -

💡If you have installed Python through the Microsoft Store, replace py with python in the command above.

Run poetry once to check if it's installed.

poetry --version

Virtual Environments folder

Poetry will save the virtual enviromentson in the .poetry/envs folder. You can change that setting and store your virtual environment in the project folder by running

poetry config virtualenvs.in-project true

Initialize a new project

To initialize a new project, run the following command in your terminal:

poetry init

Poetry will ask you some questions about your project. You can leave the default values by pressing Enter or enter your own values.

Example:

This command will guide you through creating your pyproject.toml config.

Package name [your-project-name]:
Version [0.1.0]:
Description []:
Author [Your Name <your.email@example.com>, n to skip]:
License []:
Compatible Python versions [^3.10]:

Would you like to define your main dependencies interactively? (yes/no) [yes] no
Would you like to define your development dependencies interactively? (yes/no) [yes] no

After the initialization, you will see a new file called pyproject.toml in your project folder. This file contains all the information about your project and the dependencies.

Add dependencies

To add a dependency, run the following command in your terminal:

poetry add robotframework

You can also add multiple dependencies at once:

poetry add robotframework robotframework-browser robotframework-requests

On the first run, poetry will create a virtual environment for your project and install the dependencies.

Run Commands in the Virtual Environment

To run commands in the virtual environment, you can use the poetry run command.

poetry run robot --version

To e.g. install the playwright dependencies for robotframework-browser, you can run the following command:

poetry run rfbrowser init

You can also use the poetry shell command to open a shell in the virtual environment.
All commands you run in this shell will be executed in the virtual environment.

poetry shell
(.venv) robot --version

Check out the official documentation for more information.

There is also a great Lightning Talk Project and package management: Poetry for robots from RoboCon 2022