In this section, we are going to see some fundamental concepts on Robot Framework.
This section explains the core concepts of Robot Framework:
Settings, Test Cases, Keywords, Variables, Test Suites, Tags, Documentation, and Metadata.
1. Settings
The *** Settings *** section is the first and most important part of any .robot file.
It defines configurations, imports, and metadata that apply to the entire test suite.
You can use this section to:
- Import external libraries like SeleniumLibrary
- Add resource files
- Define suite-level setup or teardown
- Provide metadata (author, version, environment)
Example:
The information in the Metadata section appears in the generated HTML report after test execution.
2. Test Cases
A test case in Robot Framework represents a single automated scenario (similar to one manual test case).
All test cases are written under the section: *** Test Cases ***
Example Test Cases
Explanation:
This test opens the Chrome browser, navigates to Google, checks if the page title is “Google,” and then closes the browser.
Each line inside a test case uses keywords, which represent individual action steps.
3. Keywords
Keywords are the building blocks of Robot Framework.
They describe what actions to perform, such as clicking a button, typing text, or verifying a condition.
There are two types of keywords:
a) Built-in Keywords
Provided by Robot Framework itself or by external libraries (like SeleniumLibrary, RequestsLibrary, etc.).
Explanation:
Log prints a message in the report.
Should Be Equal verifies that two values are the same.
Sleep 2s pauses the test for 2 seconds.
b) User-Defined Keywords
Created by users to group repeated actions and make tests reusable and readable.
Example:
Explanation:
Here, Open Google is a custom keyword (like a function in programming).
You can reuse it across multiple test cases.
4. Variables
Variables help avoid hardcoding values and make tests easier to maintain.
All variables are written under the section:
Common variable types:
|
Type |
Example |
Description |
|
Scalar |
${URL} |
Single value |
|
List |
@{BROWSERS} |
Multiple values |
|
Dictionary |
&{USER} |
Key-value pairs |
Example:
5. Tags
Tags help categorize and filter your tests.
They’re written right below the test name using [Tags].
Example:
You can run specific tagged tests:
This is useful in CI/CD pipelines or selective test execution.
6. Documentation
You can describe what a test or keyword does using [Documentation]. This improves readability and helps others understand the purpose of each test.
Example (Test Case level):
Example (Keyword level):
7. Metadata
Metadata adds extra information about a suite, such as the author, version, or environment.
It is defined under the section:
Example:
These details appear in the HTML report after test execution.
Summary Table
|
Concept |
Purpose |
Example Section |
|
Test Case |
Defines a single scenario to test |
*** Test Cases *** |
|
Keyword |
Describes Steps or reusable actions |
*** Keywords *** |
|
Variable |
Stores data for reuse |
*** Variables *** |
|
Test Suite |
Group Test Cases Logically |
.robot file or folder |
|
Tag |
Categorize and filter tests |
[Tags] smoke |
|
Documentation |
Add readable explanation |
[Documentation] ... |
|
Metadata |
Add suite-level info |
Metadata Author Tester |