Browser Library Skill
Browser Library drives Chromium, Firefox and WebKit through Playwright: auto-waiting actions, retrying assertions, one isolated context per session. It is the default for new web tests; for suites that already import SeleniumLibrary, use rf-selenium. Verified against Browser 19.14.2, Robot Framework 7.4.
When to use
Load this skill first, before exploring the project or answering from memory, when a Robot Framework web UI test uses Browser Library (Library Browser, Playwright):
- writing or fixing a web test: pages, contexts and tabs, CSS/text/XPath selectors including iframes and shadow DOM, auto-waiting, assertions with an operator, downloads, storage state;
- a click or selector times out (
TimeoutError: locator.click), or the user mentions Browser Library, Playwright or rfbrowser, even if they only say "browser lib"; - a new web test with no library chosen yet: Browser Library is the default.
Not this skill: suites that import SeleniumLibrary or run on WebDriver/Selenium Grid use rf-selenium; installing the library or errors in its Node.js rfbrowser init step use rf-setup.
Installation
Install into the project environment (see rf-setup for uv/venv/Poetry, CI and troubleshooting; follow the project's existing tool):
bashuv add "robotframework-browser[bb]" uv run rfbrowser install chromium
BrowserBatteries ([bb]) ships the Playwright wrapper, so no Node.js is needed. rfbrowser install downloads the browser binaries.
Node.js escape hatch — only if no BrowserBatteries wheel exists for your platform, or you need Node plugins (Node 22/24/26 LTS):
bashuv add robotframework-browser uv run rfbrowser init chromium
Don't mix the paths: rfbrowser install belongs to [bb], rfbrowser init to the Node.js path.
Import and defaults
Import the library without arguments; its defaults are the recommendation: strict mode on, timeout=10s for actions and waits, retry_assertions_for=1s, auto_closing_level=TEST, and a screenshot on every failing Browser keyword.
robotframework*** Settings *** Library Browser Suite Setup Open Test Browser Test Setup New Page ${URL} *** Variables *** ${URL} https://example.com *** Keywords *** Open Test Browser New Browser chromium headless=True New Context viewport={'width': 1280, 'height': 800}
The browser and context opened in Suite Setup live until the suite ends; each test gets a fresh page that is closed at test end. Use a new context per test when tests must not share cookies or storage, or per user in multi-user tests — see references/browser-context-page.md. Reuse a login with storageState — see references/authentication-storage.md.
Which keyword for which situation
| Situation | Use | Details |
|---|---|---|
| Click, hover, check | Click, Hover, Check Checkbox (auto-wait for actionability) | references/locators.md |
| Enter text | Fill Text; Type Text when key events matter; Fill Secret for passwords | — |
Choose from a <select> | Select Options By select#country value US | — |
| Assert text, URL, count, state | Getter + operator: Get Text h1 == Welcome, Get Url contains /home, Get Element Count li == 3 | references/assertion-engine.md |
| Wait for appear/disappear | Wait For Elements State .spinner hidden | references/assertion-engine.md |
| Wait for page load or an API call | Wait For Load State networkidle; Promise To Wait For Response **/api/items before the click, Wait For after it | references/troubleshooting.md |
| Retry any getter until true | Wait For Condition Text h1 == Done | references/assertion-engine.md |
| Element inside an iframe or shadow DOM | Click iframe#pay >>> button#submit; CSS pierces open shadow roots | references/iframes-shadow-dom.md |
| Popup, new tab, several pages | Switch Page NEW, Get Page Ids, Close Page | references/browser-context-page.md |
| Log in once, reuse the session | Save Storage State, then New Context storageState=${state} | references/authentication-storage.md |
| Upload or download a file | Upload File By Selector; Promise To Wait For Download + Wait For | references/downloads-uploads.md |
| Run JavaScript on the page | Evaluate JavaScript ${None} () => document.title | — |
Agent workflow
- Look up each keyword before you use it:
robotcode doc keyword Browser "<Keyword>"; find names withrobotcode doc keywords Browser "<text>". Copy names and arguments exactly as robotcode shows them. - Write the test with the defaults above and the decision table.
- Check the changed files statically:
robotcode analyze code <changed files>(through the project environment, e.g.uv run robotcode …). Fix every error it reports. - Run them by longname:
robotcode robot -bl "<Suite.Sub.Test>"(longnames fromrobotcode discover tests), or pass a whole directory. Don't pass a single.robotfile: it skips the parent__init__.robot. - Read the results:
robotcode results show --failed, thenrobotcode results log -bl "<longname>". Don't parse output.xml by hand. - Fix the cause and go back to step 3 (static check). Stop when the tests pass or the failure is shown to be in the system under test, and say which.
Selector strategy
Prefer, in order: test ids ([data-testid="save"]), accessible roles (role=button[name="Save"]), short CSS, text (text=Save), XPath last. Narrow with >> chaining (.cart >> text=Remove) or >> nth=0 instead of long absolute paths. Details: references/locators.md.
Gotchas
- Strict mode fails on several matches — actions and getters fail when a selector matches more than one element, because the import default is
strict=True. Make the selector unique or add>> nth=0; switch it off for one scope withSet Strict Mode Falseonly when the page really has duplicates. - A plain getter does not retry —
${t}= Get Text h1followed byShould Be Equalchecks once. Getters with an assertion operator (Get Text h1 == Welcome) retry forretry_assertions_for(default 1 s). Put the operator in the getter; for longer waits raise it withSet Retry Assertions Foror useWait For Condition, and never addSleep. - Two different timeouts —
timeout(default 10 s,Set Browser Timeout) bounds actions and waits;retry_assertions_forbounds assertion retries. A slow assertion needs the second one raised, not the first. Wait Until Network Is Idleis deprecated — useWait For Load State networkidle, or better wait for the element or response you need (Wait For Elements State,Wait For Response).Fill Textsets the value in one step — it fills and fires one input event, so key handlers (autocomplete, masks) never see keystrokes. UseType Text(keydown/keypress/keyup per character) orPress Keysthere.Fill Secretrejects${password}— it takes a Robot Framework 7.4Secretvariable, or the name as$password/%ENV_VAR, so the value is not logged. A plain${password}string fails; useFill Textif hiding is not needed.auto_closing_level=TESTcloses what a test opened — contexts and pages created inside a test close when it ends; those from Suite Setup live until suite teardown. Open shared browser/context in Suite Setup.KEEPleaves browsers and the node process running and is meant for local development only, not CI.New Pagewithout a browser uses defaults — it silently runsNew BrowserandNew Contextwith default values (headless Chromium, default viewport), so aviewport,storageStateorhttpCredentialsyou meant to set is missing. CallNew BrowserandNew Contextfirst.- Selector shortcuts — a selector starting with
//or..is XPath, one in quotes ("Login") is exact text, anything else is CSS;text=Loginmatches case-insensitively as a substring. A cell that starts with#is a Robot Framework comment: writeid=loginor\#login. XPath does not pierce shadow roots; frames need>>>. - No screenshot teardown needed —
run_on_failuredefaults toTake Screenshot fail-screenshot-{index}, so aRun Keyword If Test Failed Take Screenshotteardown only duplicates it.
When to read the references
| Read | When |
|---|---|
references/locators.md | a selector is ambiguous, brittle, or needs chaining, nth=, :has() or role selectors |
references/assertion-engine.md | you need an operator other than ==/contains, validate, or custom wait logic |
references/browser-context-page.md | several browsers, contexts or users; popups and tabs; video/tracing; closing levels |
references/iframes-shadow-dom.md | an element sits inside an iframe or a web component |
references/authentication-storage.md | reusing a login, HTTP auth, cookies or local/session storage |
references/downloads-uploads.md | a test uploads or downloads files |
references/troubleshooting.md | a run fails with an error message you need to decode |
Examples in assets/examples/: basic-web-test.robot, form-handling.robot, authentication-flow.robot, iframe-shadow-dom.robot.
Companion Skills
| Need | Skill |
|---|---|
| Web UI tests with SeleniumLibrary (WebDriver) | rf-selenium |
| Install Robot Framework or a library, fix the environment | rf-setup |
| Write tests, suites, user keywords, resources and variables in Robot Framework syntax | rf-language |
For running, discovering, keyword documentation, result analysis and debugging with the robotcode CLI, use the robotcode skill of the robotcode plugin (robotcode@robotframework-agent-plugins); the commands above work without it.


