Cross_Column

Tuesday, 2 June 2026

Framework Development



Robot Framework Framework Development Tutorial | Project Structure, Resource Files, Data Driven Testing

Framework Development in Robot Framework

Welcome to the Framework Development phase of Robot Framework Tutorial Series. In this tutorial, we will learn how to create a proper automation framework using Robot Framework.

  • Project Structure / Framework Design
  • Resource Files
  • Data-Driven Testing
  • Python + Robot Framework Integration

15. Project Structure / Framework Design

Framework design is one of the most important concepts in automation testing. A good framework makes automation:

  • Easy to maintain
  • Reusable
  • Scalable
  • Easy to debug

Recommended Robot Framework Project Structure

RobotFrameworkProject/
│
├── tests/
│   ├── login_test.robot
│   ├── search_test.robot
│
├── resources/
│   ├── common_keywords.robot
│   ├── locators.robot
│
├── variables/
│   ├── testdata.py
│
├── libraries/
│   ├── custom_library.py
│
├── reports/
│
├── screenshots/
│
├── drivers/
│
└── requirements.txt

Explanation of Folders

Folder Purpose
tests Contains test cases
resources Contains reusable keywords and locators
variables Stores test data and variables
libraries Contains custom Python libraries
reports Stores execution reports
screenshots Stores screenshots
drivers Stores browser drivers

Benefits of Proper Framework Design

  • Easy code maintenance
  • Code reusability
  • Centralized management
  • Easy team collaboration

16. Resource Files in Robot Framework

Resource files are used to store reusable keywords and variables. They help reduce duplicate code.


Why Use Resource Files?

  • Centralized reusable code
  • Easy maintenance
  • Cleaner test cases
  • Better framework structure

Create Resource File

File Name:

common_keywords.robot

Example Resource File

*** Settings ***
Library    SeleniumLibrary

*** Keywords ***
Launch Browser
    Open Browser    https://google.com    chrome
    Maximize Browser Window

Close Application
    Close Browser

Use Resource File in Test Case

*** Settings ***
Resource    ../resources/common_keywords.robot

*** Test Cases ***
Google Test
    Launch Browser
    Close Application

Locators Resource File Example

*** Variables ***
${LOGIN_BUTTON}      xpath=//button[text()='Login']
${USERNAME_FIELD}    id=username
${PASSWORD_FIELD}    id=password

Advantages of Resource Files

  • Avoid repeated code
  • Easy locator management
  • Reusable keywords
  • Better readability

17. Data-Driven Testing in Robot Framework

Data-driven testing means executing the same test with multiple sets of data.

It is very useful for:

  • Login testing
  • Form validation
  • API testing
  • Multiple user validation

Simple Data-Driven Example

*** Test Cases ***
Login Test

    [Template]    Validate Login

    admin    admin123
    user1    password1
    user2    password2

*** Keywords ***
Validate Login
    [Arguments]    ${username}    ${password}

    Log    Username: ${username}
    Log    Password: ${password}

How It Works?

The same keyword executes multiple times with different data sets.


Benefits of Data-Driven Testing

  • Reduce duplicate test cases
  • Increase test coverage
  • Easy maintenance
  • Supports multiple test scenarios

Using External Data

Robot Framework can also read data from:

  • Excel files
  • CSV files
  • JSON files
  • Database

CSV Data Example

username,password
admin,admin123
user1,password1

Real-Time Use Case

Suppose a login page needs to be tested with 100 users. Instead of writing 100 test cases, data-driven testing allows execution using one reusable test.


18. Python + Robot Framework Integration

Robot Framework is built on Python. We can integrate Python functions directly into Robot Framework.


Why Integrate Python?

  • Custom logic implementation
  • API handling
  • Database operations
  • Complex validations
  • File handling

Create Python Library

File Name:

custom_library.py

Python Function Example

def add_numbers(a, b):
    return int(a) + int(b)

Use Python Library in Robot Framework

*** Settings ***
Library    ../libraries/custom_library.py

*** Test Cases ***
Addition Test

    ${result}=    Add Numbers    10    20

    Log    ${result}

Expected Output

30

Python File Handling Example

def write_data():
    file = open("sample.txt", "w")
    file.write("Welcome to Way2Testing")
    file.close()

Use Python Function in Robot Framework

*** Settings ***
Library    ../libraries/custom_library.py

*** Test Cases ***
Write File Test

    Write Data

Advantages of Python Integration

  • Powerful custom automation
  • Advanced validations
  • Supports external libraries
  • Flexible framework design

Best Practices for Framework Development

  • Use modular framework structure
  • Create reusable keywords
  • Store locators separately
  • Avoid hardcoded test data
  • Use Python for complex operations

Complete Framework Flow Example

Project Structure
    ↓

Resource Files
    ↓

Reusable Keywords
    ↓

Data-Driven Test Cases
    ↓

Python Integration
    ↓

Execution & Reporting

Conclusion

In this tutorial, we learned:

  • Project Structure / Framework Design
  • Resource Files
  • Data-Driven Testing
  • Python + Robot Framework Integration

These concepts are very important for creating real-time automation frameworks used in companies.

In upcoming tutorials, we will learn:

  • API Automation
  • JSON Handling
  • Database Testing
  • Parallel Execution

Frequently Asked Questions (FAQ)

What is framework design in Robot Framework?

Framework design defines how automation code is organized and maintained.

Why are resource files important?

Resource files help create reusable keywords and reduce duplicate code.

What is data-driven testing?

Data-driven testing executes the same test with multiple data sets.

Can Robot Framework use Python functions?

Yes, Robot Framework can directly use Python libraries and functions.

No comments:

Post a Comment

Few More

CI/CD & Industry Usage

CI/CD in Robot Framework | Git, GitHub, Jenkins, Bitbucket & GitHub Actions CI/CD & I...