SeleniumLibrary and Browser Automation Integration: Core Concepts and Mental Model
Build the browser-automation mental model from Robot test and domain resource through SeleniumLibrary/WebDriver or Browser/Playwright to local browser state, assertions, evidence, and deterministic cleanup.
Learning objectives
- Trace browser automation from Robot test intent through a domain resource, external browser library, browser engine, local AUT, and result evidence.
- Separate Robot Framework library lifetime from WebDriver session state and Browser/Playwright browser-context-page state.
- Explain why SeleniumLibrary and Browser are alternative browser integration stacks rather than two interchangeable keyword catalogs.
- Choose inspection, waiting, assertion, screenshot, and cleanup responsibilities without fixed sleeps or hidden global state.
- Recognize browser artifacts as sensitive evidence even when the test target is disposable.
Current compatibility baseline — verified 2026-08-31.
Robot Framework 7.4.2 is the stable course
baseline. SeleniumLibrary 6.9.0 is paired in these
labs with Selenium 4.44.0 because 6.9.0 documents
support through that Selenium version; use Python 3.10+ for this
chapter. Browser 20.4.0 requires Python 3.10+ and
Robot Framework 7.1.1+, and its release is tested with Playwright
1.62.1. The easiest Browser path uses
robotframework-browser[bb] plus
rfbrowser install; the Node-managed path supports Node
22/24 LTS and Node 26. Re-check current compatibility before
upgrading any layer. No paid browser cloud, production site, real
credential, Pabot, container, or CI account is required.
1. The problem: Robot makes browser tests readable, but the browser still owns real state
The preceding chapters built a reliable Robot execution model:
explicit variables, lifecycle, control flow, failure semantics,
result evidence, and command-line selection. Browser automation adds
a second execution system underneath Robot. A keyword such as
Sign In As may look like one business step, but
underneath it a browser library locates elements, interacts with a
browser engine, changes page/session state, waits for conditions,
and returns observations to Robot.
The dedicated Selenium course already teaches browser-testing fundamentals. This chapter does not repeat WebDriver theory, selector fundamentals, or browser administration. Instead it answers the Robot-specific question: where should browser capability enter a Robot project, which layer owns lifecycle, and how do we preserve truthful evidence?
2. Read-only preflight before any browser mutation
python --version
python -m robot --version
python -m pip show robotframework-seleniumlibrary selenium robotframework-browser
# Browser only, if installed:
rfbrowser --version
# Confirm the local target is loopback before opening a browser.
python -c "import urllib.request; print(urllib.request.urlopen('http://127.0.0.1:8765/', timeout=2).status)"
Version inspection changes no browser or application state. The HTTP probe reads only the loopback fixture. Record the Python interpreter, Robot version, library versions, browser-engine prerequisites, target URL, current working directory, and existing result directory before execution. If the URL is not loopback/private and explicitly approved, stop.
3. Mental model: one Robot step crosses several ownership boundaries
flowchart TD
A[Robot test] --> B[Domain user keyword / resource]
B --> C{Browser library boundary}
C -->|SeleniumLibrary| D[Selenium WebDriver]
C -->|Browser| E[Playwright via Browser node side]
D --> F[Browser session]
E --> G[Browser + context + page]
F --> H[Local AUT]
G --> H
H --> I[DOM / URL / application state]
I --> C
C --> B
B --> J[Assertion + Robot status]
J --> K[output.xml / log / screenshot / trace]
The first arrow is intent: the test says what outcome matters. The resource turns that intent into browser operations. SeleniumLibrary delegates to Selenium/WebDriver; Browser delegates to Playwright through its own runtime. Both mutate a real browser. The browser mutates or observes the local application. Assertions return truth to Robot, which owns the test status and result files. A screenshot or trace is evidence of browser state, not the browser state itself.
4. Define every state store before using it
| State | Owner | Examples | Cleanup / evidence contract |
|---|---|---|---|
| Robot suite/test state | Robot Framework | test status, local variables, setup/teardown | Robot lifecycle; output.xml/log prove status |
| Resource keyword design | Repository |
Sign In As, locator mapping, domain vocabulary
|
Version-controlled source; no hidden browser singleton |
| SeleniumLibrary state | SeleniumLibrary + driver cache | WebDriver references/aliases, timeout settings | Close All Browsers in owned teardown |
| WebDriver session | Browser driver / browser | cookies, tabs/windows, DOM references | Close only sessions opened by this test/suite |
| Browser library state | Browser library runtime | timeouts, node-side connection, browser IDs | Library/runtime is not the same as a page/context |
| Playwright browser context/page | Browser/Playwright | cookies/storage per context, pages, route state | Close current owned browser/context; prefer per-test isolation |
| AUT state | Local HTTP fixture | DOM, hash URL, synthetic login result | Disposable loopback target only |
| Evidence artifacts | Robot output directory | screenshots, Browser trace, log/report | Retain first failure; review for secrets/PII |
| Credentials/trust | Caller / secret provider | real passwords, tokens, cookies |
This chapter uses only demo/mode; never put
real values in screenshots/logs
|
5. SeleniumLibrary stack versus Browser stack
SeleniumLibrary is a Robot test library over Selenium 4. Opening a browser creates a WebDriver session. Modern Selenium uses Selenium Manager to resolve/manage browser drivers on supported platforms, but the actual browser must still be available and network-restricted machines may need pre-provisioning.
Browser is a Robot library over Playwright. Its
model is explicit: a browser can own one or more contexts, and a
context owns pages. Browser 20.4.0 can be installed with
BrowserBatteries so the learner does not have to manage Node
manually; Playwright browser binaries are then installed with
rfbrowser install, or a preinstalled Chrome/Edge
channel can be used.
| Concern | SeleniumLibrary 6.9.0 | Browser 20.4.0 |
|---|---|---|
| Underlying engine | Selenium 4 / WebDriver | Playwright 1.62.1 |
| Python baseline for this chapter | 3.10+ | 3.10+ |
| Browser runtime | Installed browser; Selenium Manager normally handles driver | Playwright browser binaries or a Chromium channel |
| Primary lifecycle vocabulary | Open/Close Browser; WebDriver session | New Browser → New Context → New Page |
| Waiting style |
Explicit Wait Until... keywords around
application conditions
|
Playwright actionability auto-wait + Browser retrying assertions; explicit waits when business readiness needs them |
| Evidence | Robot log + Capture Page Screenshot |
Robot log + Take Screenshot + optional
Playwright trace
|
| Best course use | Mature Selenium estate / WebDriver interoperability | Modern Playwright semantics / context isolation / rich tracing |
6. Domain keywords are the stability seam
Do not let business-facing tests become selector scripts. The test
should say Sign In As and
Welcome Should Be Visible. A resource owns concrete
selectors and library calls. This isolates implementation churn:
replacing a CSS locator or changing browser stacks should not force
every business test to change.
*** Test Cases ***
User Can Sign In
Sign In As demo mode
Welcome Should Be Visible demo
The test owns scenario intent; the resource owns browser mechanics; the external library owns engine calls; the browser owns cookies/DOM/page state. That dependency direction is the maintainability payoff of Robot Framework.
7. Waiting is a contract, not a delay
SeleniumLibrary waits are explicit polling assertions: for example,
Wait Until Element Is Visible repeatedly checks a
locator until it is visible or the bounded timeout fails. Browser
benefits from Playwright actionability waiting for actions such as
Click. Browser also retries getter assertions such as
Get Text … == …; a getter used only to return a value
does not gain that assertion retry. When readiness is not the direct
action/assertion condition, use a condition-specific wait—not
Sleep.
Do not translate “Browser auto-waits” into “Browser waits for my whole application.” It waits for supported actionability/assertion conditions. A background job, spinner, custom readiness flag, or eventual backend state may still need an explicit bounded condition.
8. Library lifecycle is not browser lifecycle
Importing SeleniumLibrary or Browser makes
keywords available. It does not mean a browser is already open.
Conversely, closing a page is not necessarily closing a browser
runtime. In this course, the safe default is per-test browser
isolation unless an exercise explicitly proves a different ownership
model. The setup opens exactly what the test owns; teardown closes
exactly that owned browser state.
Never “clean up” by killing every Chrome, Firefox, Edge, WebDriver, or Node process on the machine. That can destroy unrelated developer sessions and CI workers. Use library-level handles and lifecycle keywords.
9. Browser evidence is useful—and sensitive
A screenshot can expose typed values, names, URLs, and account state. A Playwright trace can be even richer: DOM snapshots, network-related information, console messages, and action history may reveal more than a screenshot. This chapter uses synthetic credentials only. In production, artifact retention and access controls are part of the test design, not a postscript.
10. DevOps connection
Browser tests are usually slower and more stateful than API/unit checks. Robot gives them a readable orchestration layer, but CI trust still depends on deterministic selection, isolated browser state, bounded waits, precise failures, and retained artifacts. A browser test that “passes after a sleep” is weaker evidence than one whose readiness condition and lifecycle are explicit.
Knowledge check
Does importing Browser create a Playwright browser and page?
No. Importing the library exposes keywords and initializes library-side capability. Browser/context/page lifecycle is created explicitly with keywords such as New Browser, New Context, and New Page.
Why is a domain resource better than placing locators directly in every test?
It centralizes implementation-specific browser details while keeping tests focused on intent. Locator/library changes then have one ownership layer instead of many duplicated call sites.
A Browser Click succeeds, but the following application-specific export is not ready. Does auto-wait guarantee readiness?
No. Actionability waiting proves the click target was actionable; it does not prove unrelated business processing finished. Wait on the specific observable readiness condition.
Why should teardown not kill all chrome processes?
Process names are not ownership. It can terminate unrelated user/worker sessions. Close the browser/session/context opened by this test through the library lifecycle.
11. Summary and bridge
The browser integration model is now explicit: Robot intent → domain resource → external browser library → browser engine/state → assertions → evidence. Lesson 2 turns that model into a disposable local workflow and runs the same login-like intent through both stacks.
References and version anchors
- Robot Framework 7.4.2 User Guide — suite/resource/library lifecycle, variable/result behavior, and external-library boundary.
- SeleniumLibrary documentation and SeleniumLibrary 6.9.0 on PyPI — Selenium 4 integration, WebDriver lifecycle, waits, screenshots, and current compatibility.
- Robot Framework Browser documentation, installation, waiting concepts, and logging/tracing — Browser 20.4.0 / Playwright integration.
- Browser 20.4.0 on PyPI — Python and package release anchor.
- DevOps Academy Selenium course — prerequisite browser-testing principles; this chapter focuses on the Robot Framework integration layer.
Keep the academy open
Support free, practical DevOps education.
Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0
Send only Ethereum/ERC-20 compatible assets to this
address.