Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
GimmeJob
Sign in
Test automation · Robot Framework · Chapter 04 / 07

Test automation learning path

04 · Web UI with Browser

Install Browser Library correctly, apply Playwright-style isolation, locators, assertions and evidence.

Installation routes

Current Browser Library supports a bundled Node runtime (python -m pip install 'robotframework-browser[bb]' then rfbrowser install) and the external Node.js route (python -m pip install robotframework-browser then rfbrowser init). These are alternatives, not consecutive steps. Use a fresh context for each test, stable locators and state-based assertions.

Browser Library: web automation foundation

Use the Playwright-backed Browser Library with explicit browser lifecycle and strong locators.

Browser Library is a modern web-automation library built on Playwright. It is separate from Robot core.

# Bundled Node runtime (recommended on supported platforms):
python -m pip install "robotframework-browser[bb]"
rfbrowser install
# OR bring your own supported Node.js:
python -m pip install robotframework-browser
rfbrowser init

A minimal suite:

*** Settings ***
Library    Browser

*** Test Cases ***
Robot Framework Browser Site Opens
    New Browser    chromium    headless=${True}
    New Context
    New Page    https://robotframework-browser.org
    Get Title    *=    Robot Framework Browser
    Take Screenshot
    Close Browser

Run it:

python -m robot --outputdir results browser.robot

Think in three lifecycle levels: Browser process, Context, Page. A context isolates cookies/storage and is often the right unit for test isolation. A page is a tab.

Prefer locators based on stable user-facing semantics or dedicated test IDs over brittle DOM structure. Browser Library supports CSS and other selector engines; choose locators that describe the element's identity rather than its incidental position.

SeleniumLibrary also exists and is mature. Choose based on the existing project, browser requirements and team ecosystem. For a new Robot web suite, Browser Library is often the more direct route to Playwright capabilities.

Key points

  • Browser, Context and Page are distinct lifecycle objects
  • Use rfbrowser install with BrowserBatteries or rfbrowser init with external Node.js
  • Prefer stable semantic/test-id locators

Common pitfalls

  • Treating Browser Library like Selenium and carrying over manual-wait and locator habits unchanged

Browser assertions, waiting and page-level keywords

Build stable UI tests around retried assertions rather than sleeps.

Browser Library's waiting model is one of its most important features. Many getters become retrying assertions when you pass an assertion operator. Without an operator they read once.

Get Text    css=.status    ==    Ready

The line above retries according to the assertion timeout. This line does not:

${status}=    Get Text    css=.status

For conditions that are not naturally covered by a getter assertion, use Wait For Condition or Wait For Function. Avoid fixed Sleep except when the delay itself is what you are testing.

Put low-level selectors and mechanics into page/component keywords:

*** Keywords ***
Login As
    [Arguments]    ${username}    ${password}
    Fill Text    id=username    ${username}
    Fill Secret    id=password    $password
    Click    role=button[name="Sign in"]
    Get Url    *=    /dashboard

Then tests can stay at the domain level. Keep assertions close to the behavior they verify. A page keyword may assert that a transition completed when that postcondition is intrinsic to the action; broader business assertions should remain visible in the test.

When a failure occurs, inspect Browser traces/screenshots together with Robot log.html. Evidence should explain both the Robot keyword flow and the browser state.

Key points

  • Getter plus assertion operator is also a synchronization primitive
  • Encapsulate selectors in page/component keywords
  • Prefer state-based waits over time-based sleeps

Common pitfalls

  • Reading once and immediately asserting later when a retrying getter assertion would be stable

Browser contexts, cleanup and secret input

Connect UI isolation, stable selectors and secret-handling rules.

A Browser context isolates cookies and storage, while a page is only a tab. Creating another page inside an existing context is not isolation. Ensure teardown closes the context even when assertions fail.

Context-per-test pattern (illustrative; requires Browser Library)

*** Settings ***
Library    Browser
Test Setup    Open Isolated Page
Test Teardown    Close Context

*** Keywords ***
Open Isolated Page
    New Browser    chromium    headless=${True}
    New Context
    New Page    https://robotframework-browser.org

*** Test Cases ***
Site Is Reachable
    Get Title    *=    Robot Framework Browser

For real projects, a suite-owned browser process with one test-owned context is more efficient; ensure there is a browser available before New Context and close the correct context in teardown. Fill Secret does not accept an ordinary ${password} variable; use a Robot Secret or the $password/%PASSWORD indirection. Avoid Playwright DEBUG traces containing credentials.

Use retried getter assertions instead of Sleep; capture a screenshot before closing a failed context and restrict artifact access.

Key points

  • A fresh page does not isolate browser storage
  • Secret keywords and artifacts have different disclosure risks

Common pitfalls

  • Creating a new browser for every step or reusing one logged-in context across tests

Source registry

10 chapter references
Robot Framework User Guide

Core syntax, variables, control structures, suites, execution, output files and extension APIs

Robot Framework Foundation · Official documentation
Source ↗
Robot Framework Guides

Getting started, project structure, libraries, examples and CI guidance

Robot Framework Foundation · Official guides
Source ↗
Robot Framework releases

Current stable releases, maintenance status and release notes

Robot Framework · Official release history
Source ↗
Robot Framework Standard Libraries

BuiltIn, Collections, String, DateTime, OperatingSystem, Process, XML and other bundled libraries

Robot Framework Foundation · Official documentation
Source ↗
Robot Framework Browser

Playwright-backed web automation, locators, assertions, waiting and browser lifecycle

Robot Framework Browser contributors · Official documentation
Source ↗
Robot Framework RequestsLibrary

HTTP API testing with sessionless and session-based requests

MarketSquare / RequestsLibrary contributors · Official library documentation
Source ↗
Robot Framework Python libraries

Creating custom keywords and libraries in Python

Robot Framework Foundation · Official guide
Source ↗
Libdoc

Generating and inspecting library and resource-file documentation

Robot Framework Foundation · Official documentation
Source ↗
Running tests in parallel with Pabot

Parallel suite/test execution, process count, sharding and shared resources

Robot Framework Foundation · Official guide
Source ↗
Robot Framework in GitHub Actions

Running Robot Framework in CI and preserving reports

Robot Framework Foundation · Official guide
Source ↗