Back to Blog

Robot Framework: End-to-End Testing Made Simple

June 8, 2025

Robot Framework is a popular open-source test automation framework that uses a simple syntax for writing tests in plain text. It supports acceptance testing, acceptance test-driven development (ATDD), and robotic process automation (RPA). Robot Framework is keyword-driven and extensible through libraries.


πŸ“‘ Table of Contents

  1. What is Robot Framework?
  2. Installing Robot Framework
  3. Test Structure and Syntax
  4. UI Testing Example (SeleniumLibrary)
  5. API Testing Example (RequestsLibrary)
  6. Directory Structure
  7. Run Tests and Reports
  8. CI/CD with GitHub Actions
  9. CI/CD with Jenkins
  10. Custom Libraries with Python
  11. Parallel Execution with Pabot
  12. Allure Report Integration
  13. Data-Driven Testing with Templates
  14. Dockerized Robot Framework
  15. Debugging and Logging Tips
  16. Security and Secrets Management
  17. Comparison With Other Tools
  18. Best Practices
  19. Going Further
    Conclusion
    Further Resources


1. What is Robot Framework?

Robot Framework is a generic test automation framework ideal for:

  • Acceptance Testing
  • API Testing
  • UI Testing
  • Regression Testing
  • Robotic Process Automation (RPA)

It is Python-based and supports libraries written in Python or Java.

βœ… Key Features:

  • Keyword-driven and data-driven testing
  • Rich ecosystem of libraries (SeleniumLibrary, RequestsLibrary, etc.)
  • Human-readable syntax (plain text, reStructuredText, Markdown)
  • Can be extended via custom Python libraries
  • CLI and IDE integration (e.g., VS Code with Robot Framework Language Server)


2. Installing Robot Framework

You can install Robot Framework and essential libraries using pip:

pip install robotframework
pip install robotframework-seleniumlibrary
pip install robotframework-requests

For browser automation:

pip install robotframework-browser
rfbrowser init

You can also use pipx or Docker for isolation:

pipx install robotframework


3. Test Structure and Syntax

A typical Robot Framework test suite is a .robot file with the following sections:

*** Settings ***
Library    SeleniumLibrary

*** Variables ***
${URL}     https://example.com

*** Test Cases ***
Open Homepage
    Open Browser    ${URL}    chrome
    Page Should Contain    Welcome
    Close Browser

*** Keywords ***
Login As User
    Input Text    username    user1
    Input Password    password    1234
    Click Button    login

βœ… Use the Gherkin-style (Given, When, Then) format with optional support.


4. UI Testing Example (SeleniumLibrary)

*** Settings ***
Library    SeleniumLibrary

*** Variables ***
${URL}    https://example.com

*** Test Cases ***
User Can Login
    Open Browser    ${URL}    chrome
    Input Text    id=username    testuser
    Input Password    id=password    password123
    Click Button    id=login
    Page Should Contain    Dashboard
    Close Browser

🧠 Tip: Use id, name, or XPath selectors to locate elements.


5. API Testing Example (RequestsLibrary)

*** Settings ***
Library    RequestsLibrary

*** Variables ***
${API_URL}    https://api.example.com

*** Test Cases ***
Get User Info
    Create Session    api    ${API_URL}
    GET    api    /users/1
    Status Should Be    200
    Response Should Contain    "username"

You can parse JSON with Evaluate or BuiltIn functions.


6. Directory Structure

robot-tests/
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ ui/
β”‚   β”‚   └── login.robot
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   └── user.robot
β”œβ”€β”€ resources/
β”‚   └── keywords.robot
β”œβ”€β”€ variables/
β”‚   └── global_variables.robot
β”œβ”€β”€ output/
β”‚   └── (results go here)
└── requirements.txt

βœ… Separate tests, resources, and variables for maintainability.


7. Run Tests and Reports

Run tests with:

robot tests/ui/login.robot

This generates:

  • output.xml
  • report.html
  • log.html

You can re-run failed tests:

rebot --rerunfailed output.xml --output rerun.xml tests/


8. CI/CD with GitHub Actions

.github/workflows/robot.yml:

name: Run Robot Framework Tests

on:
  push:
    branches: [main]
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.11'

      - name: Install dependencies
        run: |
          pip install -r requirements.txt
          rfbrowser init

      - name: Run Robot Framework tests
        run: |
          robot tests/

      - name: Upload report
        uses: actions/upload-artifact@v3
        with:
          name: robot-report
          path: report.html


9. CI/CD with Jenkins

Jenkinsfile example:

pipeline {
  agent any
  stages {
    stage('Install') {
      steps {
        sh 'pip install -r requirements.txt'
        sh 'rfbrowser init'
      }
    }
    stage('Test') {
      steps {
        sh 'robot tests/'
      }
    }
    stage('Archive') {
      steps {
        archiveArtifacts artifacts: '**/report.html', fingerprint: true
        publishHTML(target: [allowMissing: false, alwaysLinkToLastBuild: true,
          keepAll: true, reportDir: '.', reportFiles: 'report.html', reportName: 'Robot Report'])
      }
    }
  }
}

βœ… Requires the HTML Publisher Plugin


10. Custom Libraries with Python

You can build custom Python libraries to extend Robot Framework with your own logic and functionality.

Example custom_library.py:

class CustomLibrary:
    def hello_world(self):
        print("Hello from custom Python library!")

Usage in .robot file:

*** Settings ***
Library    custom_library.py

*** Test Cases ***
Use Custom Library
    Hello World

βœ… Custom libraries are useful for encapsulating business logic, complex workflows, or reusable utilities.


11. Parallel Execution with Pabot

Pabot allows you to run Robot Framework tests in parallel, significantly reducing execution time.

Install it:

pip install robotframework-pabot

Run tests in parallel (e.g., 4 workers):

pabot --processes 4 tests/

βœ… Especially useful for large test suites in CI/CD environments.


12. Allure Report Integration

Allure provides beautiful, detailed reports that can enhance the visibility of your test results.

Install Allure adapter:

pip install robotframework-allure

Run tests with Allure listener:

robot --listener allure_robotframework tests/
allure serve output/allure-results

βœ… Works great with GitHub Actions and Jenkins for interactive test reporting.


13. Data-Driven Testing with Templates

Robot Framework allows you to run multiple variations of a test using templates:

*** Test Cases ***
Login With Valid Credentials
    [Template]    Login Should Succeed
    user1    password1
    user2    password2

*** Keywords ***
Login Should Succeed
    [Arguments]    ${username}    ${password}
    Open Browser    https://example.com    chrome
    Input Text    id=username    ${username}
    Input Password    id=password    ${password}
    Click Button    id=login
    Page Should Contain    Dashboard
    Close Browser

βœ… Clean and scalable way to manage repetitive test logic with different input data.


14. Dockerized Robot Framework

Running Robot Framework in Docker makes it easier to isolate dependencies and integrate in CI/CD.

Dockerfile example:

FROM python:3.11-slim

RUN pip install robotframework \
    robotframework-seleniumlibrary \
    robotframework-requests \
    robotframework-browser

RUN rfbrowser init

WORKDIR /tests
COPY ./tests /tests

CMD ["robot", "."]

βœ… Run tests consistently across environments without installing tools locally.


15. Debugging and Logging Tips

Robot Framework’s log.html is a powerful debugging tool. Use built-in keywords to improve visibility:

Log    Current value is: ${some_variable}
Capture Page Screenshot

βœ… Helps identify issues faster, especially when combined with --loglevel DEBUG.


16. Security and Secrets Management

Avoid exposing credentials directly in your .robot files.

Best practices:

  • Use environment variables (os.getenv) in custom Python keywords

  • Load secrets from encrypted .env files with python-dotenv

  • Never commit secrets to version control

βœ… Secure your test pipeline when dealing with real APIs or environments.


17. Comparison With Other Tools

Robot Framework vs Cypress

Robot Framework:

βœ… Keyword-driven, better for non-devs
βœ… Built-in support for API + UI
🚫 Slower feedback, not JS-native

Cypress:

βœ… Developer-friendly, fast browser testing
🚫 Poor support for multi-browser (no Firefox/IE)
🚫 API testing is limited

Robot Framework vs Postman/Newman

Robot Framework:

βœ… Supports UI + API in same suite
βœ… Reusability with keywords
🚫 Less beginner-friendly than Postman UI

Postman/Newman:

βœ… Excellent for exploratory and manual API testing
🚫 Harder to integrate with UI tests

Robot Framework vs Playwright

Robot Framework:

βœ… Easier for QA teams
🚫 Less suited for complex UI workflows

Playwright:

βœ… Full browser control
βœ… Fast parallel execution
🚫 More code-centric (not keyword-driven)


18. Best Practices

βœ… Keep tests atomic (1 purpose/test)
βœ… Use resource files for reusable keywords
βœ… Use page objects or abstraction
βœ… Structure files by domain (e.g. login.robot, user.robot)
βœ… Use variables for URLs, credentials
βœ… Use tags for grouping tests
βœ… Parallel execution: pabot
βœ… Lint with robotframework-lint


19. Going Further

Explore powerful libraries:

  • SeleniumLibrary β€” UI/browser automation
  • RequestsLibrary β€” HTTP APIs
  • Browser (Playwright under the hood)
  • DatabaseLibrary β€” SQL validation
  • AppiumLibrary β€” Mobile testing
  • SSHLibrary, Telnet, FTP, JSON, XML

Explore plugins:

  • VS Code plugin (Robot Framework Language Server)
  • Browser recorder extension
  • Jenkins + HTML reporting


Conclusion

Robot Framework provides a powerful, readable, and modular way to test modern apps, whether UI, API, or RPA-based. It bridges the gap between QA and dev teams with its keyword-driven approach, and scales well with CI/CD tools like GitHub Actions and Jenkins.


Further Resources