Robot Framework Selenium2Library
Robot Framework Selenium2Library is a web testing library for Robot Framework, leveraging Selenium WebDriver internally. As of version 3.0.0, this project serves as a transitional wrapper for the `robotframework-seleniumlibrary` and is the final release. New development and maintenance have fully shifted to `robotframework-seleniumlibrary`.
Common errors
-
Importing test library 'Selenium2Library' failed: ModuleNotFoundError: No module named 'Selenium2Library'
cause The `robotframework-selenium2library` package is not installed in the active Python environment, or there's a typo in the library name in the Robot Framework settings.fixEnsure the library is installed: `pip install robotframework-selenium2library`. Verify the spelling and spacing in your Robot Framework `*** Settings ***` section: `Library Selenium2Library` (at least two spaces). -
Non-existing setting 'Library SeleniumLibrary'
cause Incorrect spacing in the Robot Framework settings file. Robot Framework requires at least two spaces (or a tab) between `Library` and the library name.fixCorrect the spacing in your `.robot` file: `Library SeleniumLibrary` or `Library\tSeleniumLibrary`. -
WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
cause While not directly an `robotframework-selenium2library` error, this is a very common issue when `Open Browser` is used without the corresponding browser driver being available in the system's PATH.fixDownload the appropriate WebDriver executable (e.g., `chromedriver` for Chrome, `geckodriver` for Firefox) for your browser version and place it in a directory included in your system's PATH, or specify its path directly when opening the browser: `Open Browser https://www.example.com chrome executable_path=/path/to/chromedriver`.
Warnings
- breaking As of version 3.0.0, Selenium2Library has been renamed to SeleniumLibrary and this project is a thin wrapper. It's the last release, and users are strongly advised to migrate to `robotframework-seleniumlibrary` for future development.
- deprecated The `robotframework-selenium2library` project is no longer actively developed or maintained beyond version 3.0.0. All future enhancements, bug fixes, and compatibility updates will occur in `robotframework-seleniumlibrary`.
- gotcha Prior to version 3.0.0, Selenium2Library had known compatibility issues with newer browser versions (e.g., Firefox 47.0), often requiring specific Selenium versions or browser driver configurations (like `geckodriver`). Version 3.0.0 and `SeleniumLibrary` generally have better compatibility with modern Selenium and browsers.
Install
-
pip install robotframework-selenium2library -
pip install robotframework-seleniumlibrary
Imports
- Selenium2Library
from robotframework_selenium2library import Selenium2Library
*** Settings *** Library Selenium2Library
Quickstart
*** Settings ***
Library Selenium2Library
*** Test Cases ***
Example Google Search
Open Browser https://www.google.com chrome
Title Should Be Google
Input Text name=q Robot Framework Selenium2Library
Click Button name=btnK
Title Should Contain Robot Framework Selenium2Library - Google Search
Close Browser