Robot Framework Tutorial: Learn Automation from Scratch (2026)
When I first saw Robot Framework test cases written in a keyword-driven format, I was skeptical. But after watching a manual tester write an automation script in half an hour — without writing a single line of Python — I became a believer. Robot Framework's tabular syntax makes automation accessible to non-programmers while staying powerful enough for seasoned developers.
Robot Framework is a generic open-source automation framework that uses keyword-driven testing. It has excellent libraries for Selenium, API testing, database verification, and more. This tutorial will take you from installing Robot Framework to building a complete test suite with custom keywords and data-driven tests.
Installing Robot Framework and Creating Your First Test
Robot Framework runs on Python. Install it via pip: pip install robotframework. For browser automation, also install the SeleniumLibrary: pip install robotframework-seleniumlibrary. No additional binaries are needed — Robot Framework manages the rest.
Test cases are written in plain text files with a .robot extension. The file is divided into sections: Settings, Variables, Test Cases, and Keywords. Each test case is a sequence of keywords with arguments. Run your tests with the robot command followed by the file or directory path.
*** Settings ***
Library SeleniumLibrary
*** Test Cases ***
Open Browser And Verify Title
Open Browser https://example.com Chrome
Title Should Be Example Domain
Close Browser
Working with Variables and Data-Driven Tests
Robot Framework supports ${SCALAR}, @{LIST}, and &{DICTIONARY} variables. Define them in the Variables section, in a separate resource file, or pass them via the command line. Environment variables are accessed with %{VAR_NAME} syntax.
For data-driven tests, use the [Template] setting in a test case. The test case body then becomes a series of rows with values that are passed to the template keyword. This is powerful for boundary testing — define the keyword once and feed it dozens of data rows.
*** Variables ***
${URL} https://example.com
${BROWSER} Chrome
*** Test Cases ***
Verify Login Scenarios
[Template] Login With Credentials
user1 pass1 Expected Dashboard
user2 wrong Invalid Credentials
Creating Custom Keywords and Resource Files
Custom keywords are the building blocks of Robot Framework test suites. You define them using the Keyword section, composing existing keywords into higher-level actions. Resource files let you share keywords and variables across multiple test files.
I organize keywords into layers: low-level keywords that wrap SeleniumLibrary calls (like "Click Login Button"), and high-level business keywords (like "User Logs In As Administrator"). Business keywords are the ones you share with non-technical stakeholders who review test cases.
*** Keywords ***
Login With Credentials
[Arguments] ${username} ${password}
Input Text id=username ${username}
Input Password id=password ${password}
Click Button id=login-btn
Wait Until Page Contains Element id=dashboard
Browser Automation with SeleniumLibrary
SeleniumLibrary provides over 150 keywords for browser automation. Common keywords include Open Browser, Click Element, Input Text, Select From List By Label, Wait Until Element Is Visible, and Capture Page Screenshot. The library handles implicit waits and element location strategies automatically.
For complex scenarios, use the Execute JavaScript keyword to run JavaScript in the browser. SeleniumLibrary also supports iframes, alerts, and multiple windows through keywords like Select Frame, Handle Alert, and Select Window. The library's documentation is excellent — keep it open while writing tests.
Open Browser ${URL} Chrome
Maximize Browser Window
Click Element id=register-link
Wait Until Element Is Visible id=registration-form
Select From List By Label id=country United States
Capture Page Screenshot
API Testing with RequestsLibrary
Robot Framework is not limited to UI testing. Install robotframework-requests to test REST APIs. The library wraps Python's requests library and provides keywords for GET, POST, PUT, DELETE, and PATCH. You can validate response status, headers, and body content.
Combine API and UI testing in the same workflow: use API calls to set up test data before a UI test, or use API calls to verify that the UI action produced the correct server-side state. This hybrid approach gives you the best of both worlds — fast API setup with comprehensive UI validation.
*** Settings ***
Library RequestsLibrary
*** Test Cases ***
Get User Details
Create Session api https://api.example.com
${response}= GET On Session api /users/1
Should Be Equal As Numbers ${response.status_code} 200
Should Contain ${response.text} "name": "Alice"
Organizing Tests, Tags, and CI Integration
As your test suite grows, organization becomes critical. Use directories to separate test areas (web, api, mobile). Tag test cases with smoke, regression, slow, or critical. Run specific tags using --include or --exclude on the command line.
Robot Framework generates detailed HTML reports with pass/fail statistics, execution times, and logs with screenshots on failure. The output.xml file can be fed into CI tools or converted to JUnit XML for integration with Jenkins. I also use the --variable option in CI to set environment-specific values without changing test files.
robot --include smoke --variable ENV:staging tests/
robot --exclude slow --outputdir results tests/
Frequently Asked Questions
Do I need to know Python to use Robot Framework?
Not for writing test cases. Robot Framework's keyword syntax is readable without programming knowledge. However, you need Python to create custom library keywords when the built-in libraries do not cover your needs.
Can Robot Framework test mobile applications?
Yes, through the AppiumLibrary, which integrates Robot Framework with Appium for iOS and Android mobile testing. The syntax follows the same keyword-driven pattern as SeleniumLibrary.
How do I handle dynamic waits in Robot Framework?
SeleniumLibrary provides Wait Until keywords like Wait Until Element Is Visible, Wait Until Element Is Enabled, and Wait Until Page Contains. These use polling with configurable timeouts instead of fixed sleeps.
What is the difference between a Test Case and a Keyword?
A test case is a complete scenario that tests a specific behavior. Keywords are reusable building blocks. Test cases call keywords; keywords can call other keywords. Think of keywords as functions and test cases as the scenarios that compose them.
Originally published on Ayodhyyya. Last updated June 1, 2026.