-
Notifications
You must be signed in to change notification settings - Fork 0
Setup the project
Using PyCharm (Community Edition) as the IDE
- Windows: https://www.jetbrains.com/pycharm/download/?section=windows
- Unix: https://www.jetbrains.com/pycharm/download/?section=linux
For Windows: https://www.python.org/downloads/windows/
Download Windows installer (64-bit)
with the latest version for a particular OS (recommend at least 3.11
)
- Click Install Now and follow the instructions prompted by the Python setup modal. Python will usually be installed in C:\Users<username>\AppData\Local\Programs\Python<Python Version>
- Remember to tick “Add python.exe to PATH”
In case the default PATH is too long or you are an advanced user. Select the option Customize installation
In case you forgot to tick the Add python.exe to PATH
, be sure to manually add this to your environment variable PATH by following these steps
For Windows:
Search for Edit the system environment variables
Go to Advanced
> Environment Variables
Under the section System variables
> variable Path
, add 2 new lines for Python. For example
To verify the Python is installed successfully. You can open CMD and exec the command, it should return the correct version.
$ python --version
Python 3.11.8
Open the IDE (PyCharm)
Create a new project with a Custom environment
- This sample uses the custom env type
Virtualenv
with the base Python installed on OS (above steps). - The
Virtualenv
will be initialized in the project, under the directory.venv
After creation, the virtual environment should be automatically activated. To check, open Terminal (located at the bottom part of your IDE). In the Terminal, you should see (.venv)
preceding your current working directory.
We have created the project, created a virtual environment, and successfully activated it. All we have to do is install the libraries using pip (a package installer for Python).
For example, from scratch the project is empty, run the pip
commands below one by one to install these essential libraries.
pip install robotframework
pip install robotframework-pythonlibcore
pip install robotframework-ride
pip install selenium
These libraries will be installed in the isolated .venv
of our project only.
One good practice is to save the project dependencies in a requirements.txt
file.
pip freeze > requirements.txt
If while working on the project, you decided to add more libraries, you can re-run the same command to save the newly added libraries.
If you decide to set up the same project on a different machine, or the project with existing requirements.txt
, you can install all the same dependencies saved in the requirements.txt
file. Just a single command
pip install -r ./requirements.txt
Create a .gitignore
file to ignore Virtualenv
resources and others to reduce the size of the project before pushing to SCM. For example .gitignore
contains
.venv
.idea
You are able to launch the RIDE (the IDE exclusive for Robot Framework tests) with the Virtualenv
in the project. For example, open the project in Terminal
.\.venv\Scripts\activate
ride
Or double-click to launch .venv\Scripts\ride.py