Robot Framework Tutorial
Learn Robot Framework step by step: 36 lessons in 9 chapters with examples, quizzes, diagrams and projects.
Start learning →
of lessons completed
Getting Started
- What Is Robot Framework? Meet Robot Framework, the open-source keyword-driven tool for acceptance testing and automation. See what it is for, how it works and what you will build.
- Installing Robot Framework and Running Your First Test Install Robot Framework with pip in a virtual environment, write hello.robot, run it with the robot command and read the console output and exit code.
- Running Tests and Command-Line Options Run a file, a folder or one test with the robot command, then filter by name and tag, set variables, change output paths and rerun only the failed tests.
- Output Files: log.html, report.html and output.xml Learn what Robot Framework writes after a run: output.xml, log.html and report.html. Read results, set log levels, use rebot and find why a test failed.
Syntax and Test Cases
- Robot File Syntax: Sections, Separators and Comments Learn the .robot file format: the four sections, two-space separators, the pipe format, line continuation with three dots, comments and escaping.
- Writing Test Cases and Calling Keywords Write Robot Framework test cases: call keywords with arguments, store results in variables, use named arguments, learn when tests fail and write Gherkin style.
- The Settings Section, Documentation and Metadata Learn every common entry of the Settings section: Documentation, Metadata, Library, Resource, Suite and Test Setup, Test Tags and Timeout, plus doc formatting.
- Tags, Setup and Teardown Use tags to group and select tests, and use suite and test setup and teardown to prepare and clean up. Learn the execution order and teardown behavior.
- Control Flow: IF, FOR, WHILE and TRY Learn Robot Framework control structures: IF/ELSE, inline IF, FOR with RANGE, ENUMERATE and ZIP, WHILE limits, BREAK, CONTINUE and TRY/EXCEPT/FINALLY.
Keywords and Variables
- User Keywords, Arguments and Return Values Create your own Robot Framework keywords: use [Arguments], default values, varargs, named-only and kwargs, return values with RETURN, and keyword documentation.
- Scalar, List and Dictionary Variables Learn Robot Framework variables: ${scalar}, @{list}, &{dict} and %{ENV} syntax, the Variables section, VAR, item access, slicing, inline Python and typed values.
- Variable Scopes and Built-in Variables Understand global, suite, test and local variable scope in Robot Framework, how Set Test Variable and VAR work, command-line precedence and built-in variables.
- Embedded Arguments and Return Values Write keywords whose arguments sit inside the keyword name, restrict them with regular expressions, and master return values, multiple assignment and unpacking.
- Retrying, Expecting Errors and the Run Keyword Family Use Wait Until Keyword Succeeds to retry, Run Keyword And Expect Error to test failures, Run Keyword And Return Status, Ignore Error and test timeouts.
Libraries and Resources
- Standard Libraries Overview Tour the Robot Framework standard libraries: BuiltIn, String, Collections, OperatingSystem, DateTime, Process, XML and more, with import syntax and name conflict rules.
- Resource Files and Imports Share keywords and variables across suites with .resource files. Learn import paths, ${CURDIR}, nested resources, name prefixes and a layered keyword architecture.
- Writing Python Keyword Libraries Create your own Robot Framework keyword library in Python: functions as keywords, the @keyword and @library decorators, class libraries, scope, logging and failures.
- Variable Files, Environments and libdoc Load variables from Python, YAML and JSON files, choose a test environment with get_variables or --variablefile arguments, handle secrets and document with libdoc.
Web and API Testing
- Web testing with SeleniumLibrary Drive a browser from Robot Framework with SeleniumLibrary: open a page, type, click, read text and assert results, with a runnable stand-in for the browser.
- Locators and waiting Choose stable locators (id, css, xpath, data attributes) and wait for the page properly in Robot Framework, so web tests stop failing at random.
- Browser Library (Playwright) Meet Robot Framework Browser Library, built on Playwright: auto-waiting, contexts and pages, text selectors, and how it compares with SeleniumLibrary.
- API testing with RequestsLibrary Test REST APIs in Robot Framework with RequestsLibrary: sessions, GET and POST, status codes, JSON bodies and assertions, with a runnable fake-API stand-in.
Data-driven Testing
- Template tests for data-driven testing Write data-driven tests in Robot Framework with [Template] and Test Template: one keyword, many rows of data, clear failures per row and a runnable stand-in.
- External test data: CSV, JSON and YAML Load test data from CSV, JSON and YAML files in Robot Framework: DataDriver, variable files, Python helpers and a runnable stand-in that reads the data.
- Generating test data and test matrices Generate test data in Robot Framework with FOR loops, random values with seeds, the Faker library and combination matrices, plus runnable Python stand-ins.
Reporting and CI
- Reading results, log.html and output.xml Understand the three files every Robot Framework run writes: output.xml, log.html and report.html. Log levels, rebot, screenshots and a runnable output parser.
- Run options, tags and selecting tests Control a Robot Framework run: --include, --exclude, --test, --suite, tag expressions, variables, argument files, dry runs and re-running failed tests.
- CI with GitHub Actions and parallel runs Run Robot Framework in continuous integration: a GitHub Actions workflow, exit codes, artifacts, secrets, Docker and parallel execution with pabot.
Patterns and Extensions
- Writing custom Python libraries Extend Robot Framework with your own Python library: functions as keywords, classes, the @keyword decorator, type hints, library scope and failing with messages.
- Listeners and pre-run modifiers Hook into a Robot Framework run with listeners and change a suite before it runs with pre-run modifiers: events, the listener API v3, examples and stand-ins.
- BDD and Gherkin style tests Write behavior-driven tests in Robot Framework with Given/When/Then keywords, embedded arguments, and the native .robot Gherkin style plus a runnable matcher.
- Page objects and layered architecture Structure a growing Robot Framework suite in layers: tests, business keywords, page keywords and libraries; resource files, naming and a runnable page-object stand-in.
Projects and Practice
- Project: a login and checkout web suite Plan and build a layered Robot Framework web suite for a shop: login, search and checkout scenarios, resources, tags, teardown and a runnable simulated shop.
- Project: an API test suite Build a Robot Framework API suite for a todo service: sessions, CRUD tests, negative cases, a data-driven validation table and a runnable fake API.
- Project: a data-driven calculator suite Test a Python library with a data-driven Robot Framework suite: templates, boundary tables, error cases, a custom library and a runnable table-driven checker.
- Practice exercises and interview questions Practice Robot Framework with graded exercises, a debugging checklist, common mistakes and interview questions with answers, plus runnable stand-in drills.