Package: robotframework-seleniumlibrary
ContentsIntroductionKeyword DocumentationInstallationBrowser driversUsageExtending SeleniumLibraryCommunityVersionsHistoryIntroductionSeleniumLibraryis a web testing library forRobot Frameworkthat
utilizes theSeleniumtool internally. The project is hosted onGitHuband downloads can be found fromPyPI.SeleniumLibrary works with Selenium 3 and 4. It supports Python 3.6 or
newer. In addition to the normalPythoninterpreter, it works also
withPyPy.SeleniumLibrary is based on theold SeleniumLibrarythat was forked toSelenium2Libraryand then later renamed back to SeleniumLibrary.
See theVersionsandHistorysections below for more information about
different versions and the overall project history.Keyword DocumentationSeekeyword documentationfor available keywords and more information
about the library in general.InstallationThe recommended installation method is usingpip:pip install --upgrade robotframework-seleniumlibraryRunning this command installs also the latest Selenium and Robot Framework
versions, but you still need to installbrowser driversseparately.
The--upgradeoption can be omitted when installing the library for the
first time.Those migrating fromSelenium2Librarycan install SeleniumLibrary so that
it is exposed also as Selenium2Library:pip install --upgrade robotframework-selenium2libraryThe above command installs the normal SeleniumLibrary as well as a new
Selenium2Library version that is just a thin wrapper to SeleniumLibrary.
That allows importing Selenium2Library in tests while migrating to
SeleniumLibrary.To install the last legacySelenium2Libraryversion, use this command instead:pip install robotframework-selenium2library==1.8.0With recent versions ofpipit is possible to install directly from theGitHubrepository. To install latest source from the master branch, use
this command:pip install git+https://github.com/robotframework/SeleniumLibrary.gitPlease note that installation will take some time, becausepipwill
clone theSeleniumLibraryproject to a temporary directory and then
perform the installation.SeeRobot Framework installation instructionsfor detailed information
about installing Python and Robot Framework itself. For more details about
usingpipseeits own documentation.Browser driversAfter installing the library, you still need to install browser and
operating system specific browser drivers for all those browsers you
want to use in tests. These are the exact same drivers you need to use with
Selenium also when not using SeleniumLibrary. More information about
drivers can be found fromSelenium documentation.The general approach to install a browser driver is downloading a right
driver, such aschromedriverfor Chrome, and placing it into
a directory that is inPATH. Drivers for different browsers
can be found via Selenium documentation or by using your favorite
search engine with a search term likeselenium chrome browser driver.
New browser driver versions are released to support features in
new browsers, fix bug, or otherwise, and you need to keep an eye on them
to know when to update drivers you use.Alternatively, you can use a tool calledWebdriverManagerwhich can
find the latest version or when required, any version of appropriate
webdrivers for you and then download and link/copy it into right
location. Tool can run on all major operating systems and supports
downloading of Chrome, Firefox, Opera & Edge webdrivers.Here’s an example:pipinstallwebdrivermanagerwebdrivermanagerfirefoxchrome--linkpath/usr/local/binUsageTo use SeleniumLibrary in Robot Framework tests, the library needs to
first be imported using theLibrarysetting as any other library.
The library accepts some import time arguments, which are documented
in thekeyword documentationalong with all the keywords provided
by the library.When using Robot Framework, it is generally recommended to write as
easy-to-understand tests as possible. The keywords provided by
SeleniumLibrary is pretty low level, though, and often require
implementation-specific arguments like element locators to be passed
as arguments. It is thus typically a good idea to write tests using
Robot Framework’s higher-level keywords that utilize SeleniumLibrary
keywords internally. This is illustrated by the following example
where SeleniumLibrary keywords likeInput Textare primarily
used by higher-level keywords likeInput Username.*** Settings ***DocumentationSimple example using SeleniumLibrary.LibrarySeleniumLibrary*** Variables ***${LOGIN URL}http://localhost:7272${BROWSER}Chrome*** Test Cases ***Valid LoginOpen Browser To Login PageInput UsernamedemoInput PasswordmodeSubmit CredentialsWelcome Page Should Be Open[Teardown]Close Browser*** Keywords ***Open Browser To Login PageOpen Browser${LOGIN URL}    ${BROWSER}Title Should BeLogin PageInput Username[Arguments]    ${username}Input Textusername_field${username}Input Password[Arguments]    ${password}Input Textpassword_field${password}Submit CredentialsClick Buttonlogin_buttonWelcome Page Should Be OpenTitle Should BeWelcome PageThe above example is a slightly modified version of an example in ademo projectthat illustrates using Robot Framework and SeleniumLibrary.
See the demo for more examples that you can also execute on your own
machine. For more information about Robot Framework test data syntax in
general see theRobot Framework User Guide.Extending SeleniumLibraryBefore creating your own library which extends theSeleniumLibrary, please consider would
the extension be also useful also for general usage. If it could be useful also for general
usage, please create a new issue describing the enhancement request and even better if the
issue is backed up by a pull request.If the enhancement is not generally useful, example solution is domain specific, then the
SeleniumLibrary offers public APIs which can be used to build its own plugins and libraries.
Plugin API allows us to add new keywords, modify existing keywords and modify the internal
functionality of the library. Also new libraries can be built on top of the
SeleniumLibrary. Please seeextending documentationfor more details about the
available methods and for examples how the library can be extended.CommunityIf the provided documentation is not enough, there are various community channels
available:robotframework-usersmailing list#seleniumlibraryand#seleniumlibrary-devchannels in
Robot FrameworkSlack communityRobot Framework forumhas channel for SeleniumLibrary.SeleniumLibraryissue trackerfor bug reports and concrete enhancement
requestsOther community channelsincluding paid supportVersionsSeleniumLibrary has over the years lived under SeleniumLibrary and
Selenium2Library names and different library versions have supported
different Selenium and Python versions. This is summarized in the table
below and theHistorysection afterwards explains the project history
a bit more.ProjectSelenium VersionPython VersionCommentSeleniumLibrary 2.9.2 and earlierSelenium 1 and 2Python 2.5-2.7The original SeleniumLibrary using Selenium RC API.Selenium2Library 1.8.0 and earlierSelenium 2 and 3Python 2.6-2.7Fork of SeleniumLibrary using Selenium WebDriver API.SeleniumLibrary 3.0 and 3.1Selenium 2 and 3Python 2.7 and 3.3+Selenium2Library renamed and with Python 3 support and new architecture.SeleniumLibrary 3.2Selenium 3Python 2.7 and 3.4+Drops Selenium 2 support.SeleniumLibrary 4.0Selenium 3Python 2.7 and 3.4+Plugin API and support for event friging webdriver.SeleniumLibrary 4.1Selenium 3Python 2.7 and 3.5+Drops Python 3.4 support.SeleniumLibrary 4.2Selenium 3Python 2.7 and 3.5+Supports only Selenium 3.141.0 or newer.SeleniumLibrary 4.4Selenium 3 and 4Python 2.7 and 3.6+New PythonLibCore and dropped Python 3.5 support.SeleniumLibrary 5.0Selenium 3 and 4Python 3.6+Python 2 and Jython support is dropped.SeleniumLibrary 5.1Selenium 3 and 4Python 3.6+Robot Framework 3.1 support is dropped.Selenium2Library 3.0Depends on SeleniumLibraryDepends on SeleniumLibraryThin wrapper for SeleniumLibrary 3.0 to ease transition.HistorySeleniumLibrary originally used the Selenium Remote Controller (RC) API.
When Selenium 2 was introduced with the new but backwards incompatible
WebDriver API, SeleniumLibrary kept using Selenium RC and separate
Selenium2Library using WebDriver was forked. These projects contained
mostly the same keywords and in most cases Selenium2Library was a drop-in
replacement for SeleniumLibrary.Over the years development of the old SeleniumLibrary stopped and also
the Selenium RC API it used was deprecated. Selenium2Library was developed
further and replaced the old library as the de facto web testing library
for Robot Framework.When Selenium 3 was released in 2016, it was otherwise backwards compatible
with Selenium 2, but the deprecated Selenium RC API was removed. This had two
important effects:The old SeleniumLibrary could not anymore be used with new Selenium versions.
This project was pretty much dead.Selenium2Library was badly named as it supported Selenium 3 just fine.
This project needed a new name.At the same time when Selenium 3 was released, Selenium2Library was going
through larger architecture changes in order to ease future maintenance and
to make adding Python 3 support easier. With all these big internal and
external changes, it made sense to rename Selenium2Library back to
SeleniumLibrary. This decision basically meant following changes:Create separate repository for theold SeleniumLibraryto preserve
its history since Selenium2Library was forked.Rename Selenium2Library project and the library itself toSeleniumLibrary.Add newSelenium2Libraryproject to ease transitioning from Selenium2Library
to SeleniumLibrary.Going forward, all new development will happen in the new SeleniumLibrary
project.