SeleniumLibrary Skill
Web UI tests through Selenium WebDriver. Unlike Browser Library, element keywords do not wait: every dynamic step needs an explicit wait. Use this skill for suites that already import SeleniumLibrary or need Selenium Grid; for new web tests with no library chosen, use rf-browser. Verified against SeleniumLibrary 6.8.0, 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 SeleniumLibrary (Library SeleniumLibrary, Selenium WebDriver):
- writing or fixing a SeleniumLibrary test: browser options,
id:/css:/xpath:locators, explicit waits, hover menus, frames, windows, alerts, JavaScript; - a WebDriver exception in a robot run (element not found, click intercepted, stale element), or the user mentions SeleniumLibrary, WebDriver, chromedriver or Selenium Grid.
Not this skill: Browser Library/Playwright suites, or new web tests with no library chosen, use rf-browser; installing SeleniumLibrary or a driver uses 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-seleniumlibrary
A real browser (Chrome, Firefox, Edge) must be installed; Selenium Manager (bundled with Selenium ≥ 4.6) fetches the matching driver on first use. No driver downloads or PATH setup. Offline/air-gapped machines: see rf-setup.
Import and defaults
robotframework*** Settings *** Library SeleniumLibrary timeout=10s implicit_wait=0s Suite Setup Open Browser ${BASE_URL} headlesschrome Suite Teardown Close All Browsers
timeout=10sraises the 5 s default of theWait Until …and alert keywords, because CI pages load slower than local ones.implicit_wait=0s(the default) keeps element lookups fast and explicit; waits are written asWait Until …steps.run_on_failurestays at its default,Capture Page Screenshot, so every failing SeleniumLibrary keyword leaves a screenshot in the log.Open Browserwithheadlesschrome(orchromelocally) lets Selenium Manager resolve the driver.
Use options= (for example options=add_argument("--window-size=1920,1080")), remote_url= for Selenium Grid, or Create Webdriver when you need browser flags, a grid or a custom driver service — see references/browser-setup.md.
Which keyword for which situation
| Situation | Use | Details |
|---|---|---|
| Click, type, select | Click Element, Input Text, Input Password, Select From List By Label — after a wait if the element appears late | references/locators.md |
| Element appears after navigation or AJAX | Wait Until Element Is Visible, Wait Until Page Contains Element | references/waiting-strategies.md |
| Spinner or dialog must go away | Wait Until Element Is Not Visible | references/waiting-strategies.md |
| Button becomes clickable | Wait Until Element Is Enabled | references/waiting-strategies.md |
| Assert text that loads late | Wait Until Element Contains, Wait Until Page Contains | references/waiting-strategies.md |
| Assert a state that is already settled | Element Text Should Be, Element Should Be Visible, Title Should Be | — |
| Wait for a count or any custom condition | Wait Until Keyword Succeeds + Get Element Count | references/waiting-strategies.md |
| Element inside an iframe | Select Frame … Unselect Frame | references/frames-windows.md |
| Popup window or new tab | Switch Window NEW, back with Switch Window MAIN | references/frames-windows.md |
| JavaScript alert or confirm | Handle Alert | references/frames-windows.md |
| File upload | Choose File on the <input type="file"> | — |
| Something no keyword covers | Execute Javascript with ARGUMENTS | references/javascript-execution.md |
| Extra evidence for a failure | Capture Element Screenshot, Log Source | references/troubleshooting.md |
Keyword names and arguments: robotcode doc keywords SeleniumLibrary "wait until" lists them; there is no keyword catalog in this skill.
Agent workflow
- Look up each keyword before you use it:
robotcode doc keyword SeleniumLibrary "<Keyword>"; find names withrobotcode doc keywords SeleniumLibrary "<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.
Locator rules
- A locator without a prefix matches the
idornameattribute (some keywords add more, e.g.Click Linkalso matches link text andhref). - A locator starting with
//(or(//) is XPath; everything else needs an explicit strategy:css:,xpath:,link:,partial link:,class:,tag:,data:. - Prefer
id:/css:with stable attributes (css:[data-testid="save"]); XPath for text matches only:xpath://button[normalize-space()="Save"]. - Keep locators in variables, never stored WebElements (see Gotchas).
Gotchas
- Element keywords do not wait —
Click Element,Input TextandGet Textfail at once when the element is not there yet, becauseimplicit_waitdefaults to 0 and the importtimeoutapplies only toWait …and alert keywords. Put aWait Until Element Is Visible(or… Is Enabled) before acting on anything that loads late. - Assertions check once —
Page Should Contain,Element Should Be VisibleandElement Text Should Bedo not retry. After navigation or AJAX useWait Until Page Contains,Wait Until Element Is VisibleorWait Until Element Contains. Page Should Containleaves the frame — it searches all frames and resets the selection to the main frame, because of how it walks frames. CallSelect Frameagain before the next locator inside the iframe.Select Frameis sticky — every later locator is resolved inside that frame untilUnselect Frame, so a main-page element then fails with "element not found", not with a frame error. Pair eachSelect FramewithUnselect Frame.- Headless browser names have no underscore —
Open Browseracceptsheadlesschromeandheadlessfirefox;headless_chromefails with "is not a supported browser", and there is no headless Edge name. For headless Edge useedgewithoptions=add_argument("--headless=new"). Open Browserdefaults to Firefox — thebrowserargument defaults tofirefox, so a call without it fails on machines that only have Chrome. Always pass the browser (e.g. from a${BROWSER}variable).- Implicit plus explicit waits — setting
implicit_wait(orSet Selenium Implicit Wait) makes every lookup block for up to that time, also inside the polling loop ofWait Until …keywords, so waits overshoot theirtimeoutand absence checks such asWait Until Page Does Not Contain Elementslow down. Keepimplicit_wait=0sand use explicit waits. - Stale WebElements — a
${el}= Get WebElement …stored before the page re-renders raisesStaleElementReferenceExceptionlater, because Selenium element references die with the DOM node. Pass locator strings and look elements up again. - Covered elements —
Click Elementon an element under an overlay or cookie banner fails withElementClickInterceptedException. Wait for the overlay withWait Until Element Is Not Visible, or useScroll Element Into View; a JavaScript click is the last resort because it skips the user-visible check. - Screenshot teardowns are redundant —
run_on_failurealready runsCapture Page Screenshotwhen a SeleniumLibrary keyword fails; aCapture Page Screenshotteardown only duplicates it. Change the behaviour with therun_on_failureimport argument orRegister Keyword To Run On Failure.
When to read the references
| Read | When |
|---|---|
references/browser-setup.md | you need browser options, window size, Selenium Grid (remote_url), Create Webdriver, or CI flags |
references/waiting-strategies.md | a test is flaky, you need a count or custom wait, or you tune timeouts |
references/locators.md | a locator does not match, or you need chaining, Add Location Strategy or WebElement arguments |
references/frames-windows.md | the page uses iframes, popups, new tabs or alerts |
references/javascript-execution.md | no keyword does what you need and you want Execute Javascript / Execute Async Javascript |
references/troubleshooting.md | you have an error message (stale element, click intercepted, session not created, no such frame) or need screenshots and page source |
Examples in assets/examples/: basic-web-test.robot (navigation, forms, assertions), wait-patterns.robot (explicit waits, count wait), multi-window.robot (windows, frames, alerts).
Companion Skills
| Need | Skill |
|---|---|
| Web UI tests with Browser Library (Playwright) | rf-browser |
| 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.


