New features of SeleniumLibrary 4
SeleniumLibrary 4.0.0
was released on Friday, September 20, 2019. SeleniumLibrary
supports Python 2.7
and Python 3.4+
, Selenium 3.8.2
and Robot Framework 3.0.4
and Robot Framework 3.1.2
. The latest SeleniumLibrary
version is 4.1.0. Before jumping into the feature list commands for updating the SeleniumLibrary
version.
pip3 list
Understand the version of SeleniumLibrary
already installed.
pip3 show robotframework-seleniumlibrary
Understand the location of SeleniumLibrary
already installed.
pip3 install --upgrade robotframework-seleniumlibrary
The library would be updated and after that, if the new keywords are still not found check the referenced libraries of SeleniumLibrary
in red.xml
Reviewing only the most important and recent features of SeleniumLibrary and the list is not exhaustive.
Open Browser ${url} chrome alias=${alias}
alias
is an alias given for the browser instance and it can be used for switching between browsers. When theOpen Browser
keyword is used initially a new browser is opened, but when the keyword is called again a new browser is not opened instead will switch to the already opened browser.
Get Browser Aliases
This new keyword returns a dictionary which contains aliases of all active browsers as keys
and the index as value
.
Get Browser Ids
This is another keyword which would be handy while working with multiple browsers. Get Browser Ids
keyword returns the index of all active browser as a list.
Wait Until Location Contains ${expected}Wait Until Location Is ${expected}
This is another keyword to the already rich wait until collection. When the exact expected value is not known the keyword Wait Until Location Contains
is used and use Wait Until Location Is
keyword to validate the exact expected value.
${width} ${height}= Get Window Size True

Set Window Size ${width} ${height} True
The window innerWidth innerHeight are read-only properties in DOM which represents the browser windows content area in pixels. When the newly introduced inner parameter is set to True, then the keyword modifies the HTML DOM window.innerWidth and window.innerHeight. So by using Get Window Size
and Set Window Size
in conjunction, the hardcoding of screen size can be avoided. This inner argument does not support frames. If a frame is selected, switch to default before using the keywords.

Input Text //*[@class=’gLFyf gsfi’] update clear=TrueInput Password //*[@class=’gLFyf gsfi’] update clear=True
By setting the value to true to newly introduced clear
argument the input element is cleared before the new text is typed into the element. When false, the updated text is appended to the existing text and the previous text is not cleared from the element. This is applicable while inserting the password as well.
Deprecated
Along with the introduction of many new keywords some mostly used keywords got deprecated as well. Since they were indicated in the previous version assume the impact is minimal but the alternative is more efficient and powerful.
Locator Should Match X Times //*[@class=’gLFyf gsfi’] 1
The recommendation is to use the Page Should Contain Element
keyword with the limit
argument.
Press Key //*[@class=’gLFyf gsfi’] a
The recommendation is to use the Press Keys
keywords which have a lot more options.
Select Window locator=MAIN timeout=None
The Switch Window
keyword which has optional arguments like locator, timeout and browser can do a lot more things than its predecessor with a lot of flexibility.
Based on the above facts and a months usage experience recommendation is to upgrade SeleniumLibrary
to a version greater than 4.