Learning Robot Framework with Python on a Linux machine

HomeProgramming / Test and Automation / Learning Robot Framework with Python on a Linux machine

Day 0

robotframework.org

official YouTube RF beginners tutorial

Note: This is a work in progress. I am taking notes while exploring Robot Framework and plan to revisit and refine them once I'm more comfortable with the framework. (August 2025)

1. Create a new directory to keep all files and notes related to learning the framework in one place. For example,

mkdir robotf
cd robotf

2. Create a virtual environment for Python and activate it.

python3 -m venv robotf
source robotf/bin/activate
pip3 install robotframework
Check if the framework was installed.
robot --version

3. Load the virtual environment in VS Code (or your preferred IDE/command line) and set up a basic folder structure. The project name is testbase, and it currently includes only the minimum files needed.

Robot Framework folder structure


4. Add those basic lines to file suiteA.robot.

*** Settings ***
Resource resources/common.resource
Library resources/custom_library.py
Variables resources/variables.py

From the terminal,from the root directory testbase run this:

robot --pythonpath . tests/suiteA.robot
Since the suiteA.robot file has no meaningful tests, only some setup declarations( not mandatory for a Suite File), I'm seeing the following error:
[ ERROR ] Suite 'suiteA' contains no tests or tasks.
So far, so good.

Keyword-Driven Specification

5. This website will be used for the demo.

Add those basic lines to file suiteA.robot. They represent the procedures followed by the test in the specific order.
*** Test Cases ***
Verify Browse Sweets Link
  Open Page    https://sweetshop.netlify.app/
  Click Button    Browse Sweets
  Verify Title    Sweet Shop
  Verify Url    https://sweetshop.netlify.app/sweets
This test case is named Verify Browse Sweets Link . This test case consists of four steps, where each keyword is followed by two or more spaces (ideally four for better readability) before its parameters. For instance, the keyword Open Page is used with parameter https://sweetshop.netlify.app/. Open Page is not yet defined anywhere. RF doesn't know what to do.
** Keywords ***
Open Page
  New Browser   headless=${FALSE}
  New Page   https://sweetshop.netlify.app/
Now, New Browser and New Page are also keywords, but they are built into the Browser library (a Playwright wrapper for RF). Because of this, the library needs to be included in the Settings table at the top of the file.
Library Browser
Note: Using the Browser library is one option for handling web requests in RF. For more information on its installation, read here and here. I already had Node.js, so I just ran the command in the terminal. 
pip3 install robotframework-browser
Don't forget to re-load the venv. Still , I got new error
RF-Browser dependencies not found in installation path!              Run `rfbrowser init` to install.
After running
rfbrowser init

{I repeated the deployment on a fresh ubuntu. Here is the bit that get broken without node.js. In case you don't have node.js already and you see the following error, just follow the instructions on the official site and get node.js. 
Installing node dependencies... Couldn't execute npm. Please ensure you have node.js and npm installed and in PATH.See https://nodejs.org/ for documentation
A restart might be needed. Watch out the log in the terminal, some dependencies might be missing for playwright.
warning installing robotframework-browser


I finally saw the test execute and a browser open. My next step is to find the keywords for clicking and checking page elements. Here are the docs for the built-in keywords in the Browser Library. This is the complete file with the custom keywords:
*** Settings ***
Resource   resources/common.resource
Library   resources/custom_library.py
Library   Browser
Variables   resources/variables.py
*** Test Cases ***
Verify Browse Sweets Link
  Open Page #open the page
  Click Button   Browse Sweets #find and click on button Browse Sweets
  Title Should Be   Sweet Shop # Checks the title of the page
  Url Should Be   https://sweetshop.netlify.app/sweets # Checks the URL of the page
*** Keywords ***
Open Page
  New Browser   headless=${FALSE}
  New Page   https://sweetshop.netlify.app/
Click Button
  [Arguments]   ${expected}
  Click   text=${expected}
Title Should Be
  [Arguments]   ${title}
  ${page_title} = Get Title
  Should be Equal   ${title}  ${page_title}
Url Should Be
  [Arguments]   ${url}
  ${page_url} = Get URL
  Should be Equal   ${url}   ${page_url}

Ta-daa!
 
RF passing test result