Robot Framework Examples: Practical Test Cases for Real Projects
Robot Framework examples for basic checks, data-driven templates, BDD style, web UI, API testing, files, control structures and RPA tasks you can adapt.
Read article
Robot Framework keywords are the building blocks of every test and task. Each step in a test case is a keyword call with arguments, and keywords can come from the BuiltIn library, from external libraries, from your own Python code or from user keywords written directly in test data.
Understanding where a keyword comes from explains how to find its documentation, how to fix a “No keyword with name found” error and where new functionality should be added. Every keyword falls into one of three groups.
| Type | Defined in | Example |
|---|---|---|
| Built-in keywords | The BuiltIn library, always available | Log, Should Be Equal, Set Variable |
| Library keywords | Standard or external libraries, imported in Settings | Open Browser, Create List, GET |
| User keywords | Keywords sections in suite or resource files | Log In As, Add Product To Cart |
BuiltIn is imported automatically and covers logging, verification, variables and flow control. Knowing its most common keywords saves time, because many small tasks need no extra library at all.
Log and Log To Console for messagesShould Be Equal, Should Contain and Should Be True for checksSet Variable, Set Test Variable and Set Suite Variable for valuesRun Keyword And Return Status for conditional logicWait Until Keyword Succeeds for retriesEvaluate for short Python expressionsStandard libraries ship with the framework but must be imported, for example Collections, String, OperatingSystem, DateTime and Process. External libraries such as SeleniumLibrary or RequestsLibrary are installed with pip and imported the same way through the Library setting.
*** Settings ***
Library Collections
Library OperatingSystem
Library SeleniumLibrary timeout=10s
Arguments after the library name configure the library itself. In the example above, SeleniumLibrary receives a default timeout. The Robot Framework Selenium article explains that library in depth.
User keywords combine existing keywords into higher-level steps. They are defined in a Keywords section, use the same syntax as test cases and can declare arguments, documentation, tags, return values and teardowns through bracketed settings.
*** Keywords ***
Add Product To Cart
[Documentation] Adds a product by name.
[Arguments] ${name} ${qty}=1
Search Product ${name}
Set Quantity ${qty}
Click Add Button
Get Cart Total
${total}= Read Total From Page
RETURN ${total}
The ${qty}=1 syntax gives the argument a default value. RETURN passes a value back to the caller, which then stores it with the familiar ${variable}= assignment.
Arguments can also be embedded directly into a keyword name. This makes steps read like natural sentences, which is particularly useful in behaviour-driven tests written with Given, When and Then prefixes.
*** Keywords ***
User "${name}" Is Logged In
Log In As ${name} ${DEFAULT_PASSWORD}
Keyword names are matched case-insensitively, and spaces and underscores are ignored. That flexibility helps readability, but it also means two libraries can expose keywords with the same name, which the framework reports as a conflict.
Should Be Equal and should_be_equal refer to the same keywordBuiltIn.LogResource files use the .resource extension and contain Settings, Variables and Keywords sections but no tests. Import them with the Resource setting to share keywords across suites, and group them by page, feature or domain so that each file stays focused.
| Layer | Contains |
|---|---|
| Tests | Business-level steps only |
| Resource keywords | Workflows composed from library keywords |
| Python libraries | Complex logic, parsing and integrations |
This layering mirrors the advice in the Robot Framework Python article: keep readable intent in test data and push computation into code.
The Libdoc tool generates HTML documentation for libraries and resource files, including argument lists and the text from [Documentation] or Python docstrings. Publishing this documentation lets teammates discover existing keywords before writing duplicates. The Robot Framework documentation article shows how to generate it.
Good keyword names describe intent from the reader’s point of view. A name such as Order Should Be Confirmed tells a reviewer what is verified, while Check Element Text 3 forces them to open the implementation to understand the step.
Consistent naming also makes keyword search in Libdoc and editor completion far more effective, because related keywords group together alphabetically.
User keywords support [Tags] for categorisation and [Teardown] for cleanup that must run even when a step fails. A keyword teardown is ideal for closing connections or removing temporary files created inside that keyword.
Export Report As CSV
[Tags] export
Open Export Dialog
Choose Format CSV
[Teardown] Close Export Dialog
There is no small fixed limit. Keywords can accept positional, named, default, variable-length and free named arguments, although keeping signatures short improves readability.
Yes. User keywords can call any keyword available in their scope, including other user keywords, library keywords and BuiltIn keywords.
Open the library’s Libdoc page. Standard library documentation is published on the official website, and most external libraries publish their own keyword documentation.
The framework reports that multiple keywords match the name. Resolve it by prefixing the call with the library name, such as SeleniumLibrary.Click Element, or by changing the library search order.
Steps repeated across several tests are good candidates, especially when they describe one business action. Avoid wrapping single library calls without adding meaning, because extra layers can make logs harder to follow.
Review a proposed keyword by reading its name inside a complete test. A name such as Confirm Order Total gives the reviewer a clear expectation. Put technical arguments in the underlying library call and expose only the values that help explain the case, such as the order reference and expected total in cents.
Robot Framework keywords turn automation into readable steps. Rely on BuiltIn for everyday checks, import standard and external libraries for specific technologies, build user keywords in resource files for reusable workflows and document everything with Libdoc so the team can find and reuse it.