Selenium Library
Selenium Library
SeleniumLibrary
Library version: 6.0.0
Search ✕
Library scope: GLOBAL
Keywords (173) +
A dd Cookie
A dd Location Strategy
Introduction
A lert Should Be Present
SeleniumLibrary is a web testing library for Robot Framework.
A lert Should Not Be Present
This document explains how to use keywords provided by SeleniumLibrary. For information
A ssign Id To Element
about installation, support, and more, please visit the project pages. For more information
about Robot Framework, see http://robotframework.org.
C apture Element Screenshot
C lick Image
C lick Link
C reate Webdriver
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 1/65
3/13/23, 1:57 AM SeleniumLibrary
If a locator accidentally starts with a prefix recognized as explicit locator strategy or implicit
XPath strategy, it is possible to use the explicit default prefix to enable the default
SeleniumLibrary strategy.
Examples:
The explicit locator strategy is specified with a prefix using either syntax strategy:value
or strategy=value . The former syntax is preferred because the latter is identical to Robot
Framework's named argument syntax and that can cause problems. Spaces around the
separator are ignored, so id:foo , id: foo and id : foo are all equivalent.
Locator strategies that are supported by default are listed in the table below. In addition to
them, it is possible to register custom locators.
See the Default locator strategy section below for more information about how the default
strategy works. Using the explicit default prefix is only necessary if the locator value itself
accidentally matches some of the explicit strategies.
Different locator strategies have different pros and cons. Using ids, either explicitly like
id:foo or by using the default locator strategy simply like foo , is recommended when
possible, because the syntax is simple and locating elements by id is fast for browsers. If an
element does not have an id or the id is not stable, other solutions need to be used. If an
element has a unique tag name or class, using tag , class or css strategy like tag:h1 ,
class:example or css:h1.example is often an easy solution. In more complex cases
using XPath expressions is typically the best approach. They are very powerful but a downside
is that they can also get complex.
Examples:
NOTE:
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 2/65
3/13/23, 1:57 AM SeleniumLibrary
If the locator starts with // or multiple opening parenthesis in front of the // , the locator is
considered to be an XPath expression. In other words, using //div is equivalent to using
explicit xpath://div and ((//div)) is equivalent to using explicit xpath:
((//div))
Examples:
The support for the (// prefix is new in SeleniumLibrary 3.0. Supporting multiple opening
parenthesis is new in SeleniumLibrary 5.0.
Chaining locators
It is possible chain multiple locators together as single locator. Each chained locator must start
with locator strategy. Chained locators must be separated with single space, two greater than
characters and followed with space. It is also possible mix different locator strategies, example
css or xpath. Also a list can also be used to specify multiple locators. This is useful, is some
part of locator would match as the locator separator but it should not. Or if there is need to
existing WebElement as locator.
Although all locators support chaining, some locator strategies do not abey the chaining. This
is because some locator strategies use JavaScript to find elements and JavaScript is executed
for the whole browser context and not for the element found be the previous locator.
Chaining is supported by locator strategies which are based on Selenium API, like xpath or css,
but example chaining is not supported by sizzle or `jquery
Examples:
Click Element css:.bar >> xpath://a # To find a link which is present after an element with class "bar"
List examples:
Using WebElements
Custom locators
If more complex lookups are required than what is provided through the default locators,
custom lookup strategies can be created. Using custom locators is a two part process. First,
create a keyword that returns a WebElement that should be acted on:
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 3/65
3/13/23, 1:57 AM SeleniumLibrary
Strategy
Execute return
SeleniumLibrary
${element}=
Javascript window document getElementById('${locator}');
The first argument of Add Location Strategy specifies the name of the strategy and it must be
unique. After registering the strategy, the usage is the same as with other locators:
Browser
When Open Browser or Create WebDriver keyword is called, it will create a new Selenium
WebDriver instance by using the Selenium WebDriver API. In SeleniumLibrary terms, a new
browser is created. It is possible to start multiple independent browsers (Selenium Webdriver
instances) at the same time, by calling Open Browser or Create WebDriver multiple times.
These browsers are usually independent of each other and do not share data like cookies,
sessions or profiles. Typically when the browser starts, it creates a single window which is
shown to the user.
Window
Windows are the part of a browser that loads the web site and presents it to the user. All
content of the site is the content of the window. Windows are children of a browser. In
SeleniumLibrary browser is a synonym for WebDriver instance. One browser may have
multiple windows. Windows can appear as tabs, as separate windows or pop-ups with
different position and size. Windows belonging to the same browser typically share the
sessions detail, like cookies. If there is a need to separate sessions detail, example login with
two different users, two browsers (Selenium WebDriver instances) must be created. New
windows can be opened example by the application under test or by example Execute
Javascript keyword:
The example below opens multiple browsers and windows, to demonstrate how the different
keywords can be used to interact with browsers, and windows attached to these browsers.
Structure:
BrowserA
Window 1 (___location=https://robotframework.org/)
Window 2 (___location=https://robocon.io/)
Window 3 (___location=https://github.com/robotframewor
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 4/65
3/13/23, 1:57 AM SeleniumLibrary
BrowserB
Window 1 (___location=https://github.com/)
SeleniumLibrary
Example:
Timeout
SeleniumLibrary contains various keywords that have an optional timeout argument that
specifies how long these keywords should wait for certain events or actions. These keywords
include, for example, Wait ... keywords and keywords related to alerts. Additionally
Execute Async Javascript. Although it does not have timeout , argument, uses a timeout to
define how long asynchronous JavaScript can run.
The default timeout these keywords use can be set globally either by using the Set Selenium
Timeout keyword or with the timeout argument when importing the library. See time
format below for supported timeout syntax.
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 5/65
3/13/23, 1:57 AM SeleniumLibrary
Implicit wait
SeleniumLibrary Implicit wait specifies the maximum time how long Selenium waits when searching for
elements. It can be set by using the Set Selenium Implicit Wait keyword or with the
implicit_wait argument when importing the library. See Selenium documentation for
more information about this functionality.
Selenium speed
Selenium execution speed can be slowed down globally by using Set Selenium speed keyword.
This functionality is designed to be used for demonstrating or debugging purposes. Using it
to make sure that elements appear on a page is not a good idea. The above-explained
timeouts and waits should be used instead.
Time format
All timeouts and waits can be given as numbers considered seconds (e.g. 0.5 or 42 ) or in
Robot Framework's time syntax (e.g. 1.5 seconds or 1 min 30 s ). For more
information about the time syntax see the Robot Framework User Guide.
Run-on-failure functionality
SeleniumLibrary has a handy feature that it can automatically execute a keyword if any of its
own keywords fails. By default, it uses the Capture Page Screenshot keyword, but this can be
changed either by using the Register Keyword To Run On Failure keyword or with the
run_on_failure argument when importing the library. It is possible to use any keyword
from any imported library or resource file.
Boolean arguments
Starting from 5.0 SeleniumLibrary relies on Robot Framework to perform the boolean
conversion based on keyword arguments type hint. More details in Robot Framework user
guide
Please note SeleniumLibrary 3 and 4 did have own custom methods to covert arguments to
boolean values.
EventFiringWebDriver
The SeleniumLibrary offers support for EventFiringWebDriver. See the Selenium and
SeleniumLibrary EventFiringWebDriver support documentation for further details.
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 6/65
3/13/23, 1:57 AM SeleniumLibrary
Thread support
SeleniumLibrary SeleniumLibrary is not thread-safe. This is mainly due because the underlying Selenium tool is
not thread-safe within one browser/driver instance. Because of the limitation in the Selenium
side, the keywords or the API provided by the SeleniumLibrary is not thread-safe.
Plugins
SeleniumLibrary offers plugins as a way to modify and add library keywords and modify some
of the internal functionality without creating a new library or hacking the source code. See
plugin API documentation for further details.
Importing
Arguments
timeout = 0:00:05
implicit_wait = 0:00:00
run_on_failure = Capture
Page
Screenshot
screenshot_root_directory = None <str> or <Non
plugins = None <str> or <Non
event_firing_webdriver = None <str> or <Non
Documentation
timeout : Default value for timeouts used with Wait ... keywords.
implicit_wait : Default value for implicit wait used when locating
elements.
run_on_failure : Default action for the run-on-failure functionality.
screenshot_root_directory : Path to folder where possible
screenshots are created or EMBED. See Set Screenshot Directory keyword for
further details about EMBED. If not given, the directory where the log file is
written is used.
plugins : Allows extending the SeleniumLibrary with external Python
classes.
event_firing_webdriver : Class for wrapping Selenium with
EventFiringWebDriver
Keywords
Add Cookie
Arguments
name <str>
value <str>
path = None <str> or <None>
___domain = None <str> or <None>
secure = None <bool> or <None>
expiry = None <str> or <None>
Documentation
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 7/65
3/13/23, 1:57 AM SeleniumLibrary
SeleniumLibrary name and value are required, path , ___domain , secure and expiry are
optional. Expiry supports the same formats as the DateTime library or an epoch
timestamp.
Example:
Arguments
strategy_name <str>
strategy_keyword <str>
persist = False <bool>
Documentation
See Custom locators for information on how to create and use custom strategies.
Remove Location Strategy can be used to remove a registered strategy.
Location strategies are automatically removed after leaving the current scope by
default. Setting persist to a true value (see Boolean arguments) will cause the
___location strategy to stay registered throughout the life of the test.
Arguments
text = <str>
action = ACCEPT <str>
timeout = None <timedelta> or <None>
Documentation
Fails if no alert is present. If text is a non-empty string, then it is used to verify alert's
message. The alert is accepted by default, but that behavior can be controlled by using
the action argument same way as with Handle Alert.
timeout specifies how long to wait for the alert to appear. If it is not given, the
global default timeout is used instead.
action and timeout arguments are new in SeleniumLibrary 3.0. In earlier versions,
the alert was always accepted and a timeout was hardcoded to one second.
Arguments
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 8/65
3/13/23, 1:57 AM SeleniumLibrary
If the alert actually exists, the action argument determines how it should be
handled. By default, the alert is accepted, but it can be also dismissed or left open the
same way as with the Handle Alert keyword.
timeout specifies how long to wait for the alert to appear. By default, is not waited
for the alert at all, but a custom time can be given if alert may be delayed. See the time
format section for information about the syntax.
Assign Id To Element
Arguments
Documentation
This is mainly useful if the locator is complicated and/or slow XPath expression and it is
needed multiple times. Identifier expires when the page is reloaded.
See the Locating elements section for details about the locator syntax.
Example:
Arguments
Documentation
Captures a screenshot from the element identified by locator and embeds it into
log file.
See Capture Page Screenshot for details about filename argument. See the Locating
elements section for details about the locator syntax.
Support for capturing the screenshot from an element has limited support among
browser vendors. Please check the browser vendor driver documentation does the
browser support capturing a screenshot from an element.
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 9/65
3/13/23, 1:57 AM SeleniumLibrary
SeleniumLibrary Examples:
Arguments
Documentation
Takes a screenshot of the current page and embeds it into a log file.
filename argument specifies the name of the file to write the screenshot into. The
directory where screenshots are saved can be set when importing the library or by
using the Set Screenshot Directory keyword. If the directory is not configured,
screenshots are saved to the same directory where Robot Framework's log file is
written.
Examples:
Arguments
Documentation
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 10/65
3/13/23, 1:57 AM SeleniumLibrary
See the Locating elements section for details about the locator syntax.
SeleniumLibrary
Checkbox Should Not Be Selected
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
Choose File
Arguments
Documentation
This keyword is most often used to input files into upload forms. The keyword does
not check file_path is the file or folder available on the machine where tests are
executed. If the file_path points at a file and when using Selenium Grid, Selenium
will magically, transfer the file from the machine where the tests are executed to the
Selenium Grid node where the browser is running. Then Selenium will send the file
path, from the nodes file system, to the browser.
Example:
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
Click Button
Arguments
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 11/65
3/13/23, 1:57 AM SeleniumLibrary
Documentation
See the Locating elements section for details about the locator syntax. When using the
default locator strategy, buttons are searched using id , name , and value .
See the Click Element keyword for details about the modifier argument.
Click Element
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
The modifier argument can be used to pass Selenium Keys when clicking the
element. The + can be used as a separator for different Selenium Keys. The CTRL is
internally translated to the CONTROL key. The modifier is space and case
insensitive, example "alt" and " aLt " are supported formats to ALT key . If modifier
does not match to Selenium Keys, keyword fails.
If action_chain argument is true, see Boolean arguments for more details on how
to set boolean argument, then keyword uses ActionChain based click instead of the
<web_element>.click() function. If both action_chain and modifier are
defined, the click will be performed using modifier and action_chain will be
ignored.
Example:
Click
id:button # Would click element without any modifiers.
Element
Click # Would click element with CTLR key pressed
id:button CTRL
Element down.
Click # Would click element with CTLR and ALT keys
id:button CTRL+ALT
Element pressed down.
Click # Clicks the button using an Selenium
id:button action_chain=True
Element ActionChains
Arguments
Documentation
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 12/65
3/13/23, 1:57 AM SeleniumLibrary
The Cursor is moved and the center of the element and x/y coordinates are calculated
from that point.
SeleniumLibrary
See the Locating elements section for details about the locator syntax.
Click Image
Arguments
Documentation
See the Locating elements section for details about the locator syntax. When using the
default locator strategy, images are searched using id , name , src and alt .
See the Click Element keyword for details about the modifier argument.
Click Link
Arguments
Documentation
See the Locating elements section for details about the locator syntax. When using the
default locator strategy, links are searched using id , name , href and the link text.
See the Click Element keyword for details about the modifier argument.
Documentation
After this keyword, new indexes returned from Open Browser keyword are reset to 1.
This keyword should be used in test or suite teardown to make sure all browsers are
closed.
Close Browser
Documentation
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 13/65
3/13/23, 1:57 AM SeleniumLibrary
SeleniumLibrary
Close Window
Documentation
Cover Element
Arguments
Documentation
Will cover elements identified by locator with a blue div without breaking page
layout.
See the Locating elements section for details about the locator syntax.
Create Webdriver
Arguments
driver_name <str>
alias = None <str> or <None>
kwargs = {}
** init_kwargs
Documentation
Like Open Browser, but allows passing arguments to the created WebDriver instance
directly. This keyword should only be used if the functionality provided by Open
Browser is not adequate.
The initialized WebDriver can be configured either with a Python dictionary kwargs
or by using keyword arguments **init_kwargs . These arguments are passed
directly to WebDriver without any processing. See Selenium API documentation for
details about the supported arguments.
Examples:
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 14/65
3/13/23, 1:57 AM SeleniumLibrary
# Use proxy with
PhantomJS
Returns the index of this browser instance which can be used later to switch back to it.
Index starts from 1 and is reset back to it when Close All Browsers keyword is used. See
Switch Browser for an example.
Arguments
text <str>
loglevel = TRACE <str>
Documentation
See Page Should Contain for an explanation about the loglevel argument.
Prior to SeleniumLibrary 3.0 this keyword was named Current Frame Contains.
Arguments
text <str>
loglevel = TRACE <str>
Documentation
See Page Should Contain for an explanation about the loglevel argument.
Documentation
Delete Cookie
Arguments
name
Documentation
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 15/65
3/13/23, 1:57 AM SeleniumLibrary
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
Arguments
Documentation
The locator argument is the locator of the dragged element and the target is
the locator of the target. See the Locating elements section for details about the locator
syntax.
Example:
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
The element will be moved by xoffset and yoffset , each of which is a negative
or positive number specifying the offset.
Example:
Drag And Drop By Offset myElem 50 -35 # Move myElem 50px right and 35px down
Arguments
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 16/65
3/13/23, 1:57 AM SeleniumLibrary
Documentation
See the Locating elements section for details about the locator syntax.
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 17/65
3/13/23, 1:57 AM SeleniumLibrary
Documentation
Herein, visible means that the element is logically visible, not optically visible in the
current browser viewport. For example, an element that carries display:none is
not logically visible, so using this keyword on that element would fail.
See the Locating elements section for details about the locator syntax.
The message argument can be used to override the default error message.
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
The message argument can be used to override the default error message.
The ignore_case argument can be set to True to compare case insensitive, default
is False. New in SeleniumLibrary 3.1.
Use Element Text Should Be if you want to match the exact text, not a substring.
Arguments
Documentation
Passes if the element does not exists. See Element Should Be Visible for more
information about visibility and supported arguments.
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 18/65
3/13/23, 1:57 AM SeleniumLibrary
Documentation
See the Locating elements section for details about the locator syntax.
The message argument can be used to override the default error message.
The ignore_case argument can be set to True to compare case insensitive, default
is False.
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
The message argument can be used to override the default error message.
The ignore_case argument can be set to True to compare case insensitive, default
is False.
Arguments
Documentation
Verifies that element locator does not contain exact the text not_expected .
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 19/65
3/13/23, 1:57 AM SeleniumLibrary
See the Locating elements section for details about the locator syntax.
SeleniumLibrary The message argument can be used to override the default error message.
The ignore_case argument can be set to True to compare case insensitive, default
is False.
Arguments
Documentation
Similar to Execute Javascript except that scripts executed with this keyword must
explicitly signal they are finished by invoking the provided callback. This callback is
always injected into the executed function as the last argument.
Scripts must complete within the script timeout or this keyword will fail. See the
Timeout section for more information.
Examples:
Execute Javascript
Arguments
Documentation
code may be divided into multiple cells in the test data and code may contain
multiple lines of code and arguments. In that case, the JavaScript code parts are
concatenated together without adding spaces and optional arguments are separated
from code .
If code is a path to an existing file, the JavaScript to execute will be read from that
file. Forward slashes work as a path separator on all operating systems.
The JavaScript executes in the context of the currently selected frame or window as the
body of an anonymous function. Use window to refer to the window of your
application and document to refer to the document object of the current frame or
window, e.g. document.getElementById('example') .
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 20/65
3/13/23, 1:57 AM SeleniumLibrary
This keyword returns whatever the executed JavaScript code returns. Return values are
converted to the appropriate Python types.
SeleniumLibrary
Starting from SeleniumLibrary 3.2 it is possible to provide JavaScript arguments as part
of code argument. The JavaScript code and arguments must be separated with
JAVASCRIPT and ARGUMENTS markers and must be used exactly with this format. If the
Javascript code is first, then the JAVASCRIPT marker is optional. The order of
JAVASCRIPT and ARGUMENTS markers can be swapped, but if ARGUMENTS is the first
marker, then JAVASCRIPT marker is mandatory. It is only allowed to use JAVASCRIPT
and ARGUMENTS markers only one time in the code argument.
Examples:
Execute window.myFunc('arg1',
JavaScript 'arg2')
Execute
${CURDIR}/js_to_execute.js
JavaScript
Execute
alert(arguments[0]); ARGUMENTS 123
JavaScript
Execute
ARGUMENTS 123 JAVASCRIPT alert(arguments[0]);
JavaScript
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
See Page Should Contain for an explanation about the loglevel argument.
Documentation
Documentation
Returns aliases of all active browser that has an alias as NormalizedDict. The dictionary
contains the aliases as keys and the index as value. This can be accessed as dictionary
${aliases.key} or as list @{aliases}[0] .
Example:
Open
https://example.com alias=BrowserA
Browser
Open
https://example.com alias=BrowserB
Browser
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 21/65
3/13/23, 1:57 AM SeleniumLibrary
# &{aliases} = { BrowserA=1|BrowserB=2
&{aliases} Get Browser Aliases
}
Documentation
Example:
Get Cookie
Arguments
name <str>
Documentation
If no cookie is found with name , keyword fails. The cookie object contains details
about the cookie. Attributes available in the object are documented in the table below.
See the WebDriver specification for details about the cookie information. Notice that
expiry is specified as a datetime object, not as seconds since Unix Epoch like
WebDriver natively does.
In some cases, example when running a browser in the cloud, it is possible that the
cookie contains other attributes than is defined in the WebDriver specification. These
other attributes are available in an extra attribute in the cookie object and it
contains a dictionary of the other attributes. The extra attribute is new in
SeleniumLibrary 4.0.
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 22/65
3/13/23, 1:57 AM SeleniumLibrary
Example:
Get Cookies
Arguments
Documentation
If as_dict argument evaluates as false, see Boolean arguments for more details,
then cookie information is returned as a single string in format name1=value1;
name2=value2; name3=value3 . When as_dict argument evaluates as true,
cookie information is returned as Robot Framework dictionary format. The string
format can be used, for example, for logging purposes or in headers when sending
HTTP requests. The dictionary format is helpful when the result can be passed to
requests library's Create Session keyword's optional cookies parameter.
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
Example:
Passing attribute name as part of the locator was removed in SeleniumLibrary 3.2.
The explicit attribute argument should be used instead.
Arguments
Documentation
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 23/65
3/13/23, 1:57 AM SeleniumLibrary
If you wish to assert the number of matching elements, use Page Should Contain
Element with limit argument. Keyword will always return an integer.
SeleniumLibrary
Example:
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
Example:
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
The position is returned in pixels off the left side of the page, as an integer.
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
Returns visible labels by default, but values can be returned by setting the values
argument to a true value (see Boolean arguments).
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 24/65
3/13/23, 1:57 AM SeleniumLibrary
Example:
Get Location
Documentation
Get Locations
Arguments
Documentation
Browser Scope:
The browser argument specifies the browser that shall return its windows
information.
Arguments
Documentation
If there are multiple selected options, the label of the first option is returned.
See the Locating elements section for details about the locator syntax.
Arguments
Documentation
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 25/65
3/13/23, 1:57 AM SeleniumLibrary
SeleniumLibrary Starting from SeleniumLibrary 3.0, returns an empty list if there are no selections. In
earlier versions, this caused an error.
See the Locating elements section for details about the locator syntax.
Arguments
Documentation
If there are multiple selected options, the value of the first option is returned.
See the Locating elements section for details about the locator syntax.
Arguments
Documentation
Starting from SeleniumLibrary 3.0, returns an empty list if there are no selections. In
earlier versions, this caused an error.
See the Locating elements section for details about the locator syntax.
Documentation
Documentation
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 26/65
3/13/23, 1:57 AM SeleniumLibrary
SeleniumLibrary
Get Selenium Timeout
Documentation
Get Session Id
Documentation
Get Source
Documentation
Arguments
Documentation
The table is located using the locator argument and its cell found using row and
column . See the Locating elements section for details about the locator syntax.
Both row and column indexes start from 1, and header and footer rows are included in
the count. It is possible to refer to rows and columns from the end by using negative
indexes so that -1 is the last row/column, -2 is the second last, and so on.
All <th> and <td> elements anywhere in the table are considered to be cells.
See Page Should Contain for an explanation about the loglevel argument.
Get Text
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 27/65
3/13/23, 1:57 AM SeleniumLibrary
Arguments
SeleniumLibrary
locator <WebElement> or <str>
Documentation
See the Locating elements section for details about the locator syntax.
Get Title
Documentation
Get Value
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
The position is returned in pixels off the top of the page, as an integer.
Get WebElement
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 28/65
3/13/23, 1:57 AM SeleniumLibrary
SeleniumLibrary
Get WebElements
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
Starting from SeleniumLibrary 3.0, the keyword returns an empty list if there are no
matching elements. In previous releases, the keyword failed in this case.
Arguments
Documentation
How to select the browser scope of this keyword, see Get Locations.
Arguments
Documentation
How to select the browser scope of this keyword, see Get Locations.
Arguments
Documentation
How to select the browser scope of this keyword, see Get Locations.
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 29/65
3/13/23, 1:57 AM SeleniumLibrary
Documentation
The position is relative to the top left corner of the screen. Returned values are
integers. See also Set Window Position.
Example:
Arguments
Documentation
Example:
Arguments
Documentation
How to select the browser scope of this keyword, see Get Locations.
Go Back
Documentation
Go To
Arguments
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 30/65
3/13/23, 1:57 AM SeleniumLibrary
url
SeleniumLibrary Documentation
Handle Alert
Arguments
Documentation
By default, the alert is accepted, but this can be controlled with the action argument
that supports the following case-insensitive values:
The timeout argument specifies how long to wait for the alert to appear. If it is not
given, the global default timeout is used instead.
Examples:
Input Password
Arguments
Documentation
Types the given password into the text field identified by locator .
See the Locating elements section for details about the locator syntax. See Input Text
for clear argument details.
Difference compared to Input Text is that this keyword does not log the given
password on the INFO level. Notice that if you use the keyword like
the password is shown as a normal keyword argument. A way to avoid that is using
variables like
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 31/65
3/13/23, 1:57 AM SeleniumLibrary
Please notice that Robot Framework logs all arguments using the TRACE level and tests
must not be executed using level below DEBUG if the password should not be logged
SeleniumLibrary in any format.
The clear argument is new in SeleniumLibrary 4.0. Hiding password logging from
Selenium logs is new in SeleniumLibrary 4.2.
Input Text
Arguments
Documentation
Types the given text into the text field identified by locator .
When clear is true, the input element is cleared before the text is typed into the
element. When false, the previous text is not cleared from the element. Use Input
Password if you do not want the given text to be logged.
If Selenium Grid is used and the text argument points to a file in the file system,
then this keyword prevents the Selenium to transfer the file to the Selenium Grid hub.
Instead, this keyword will send the text string as is to the element. If a file should be
transferred to the hub and upload should be performed, please use Choose File
keyword.
See the Locating elements section for details about the locator syntax. See the Boolean
arguments section how Boolean values are handled.
Disabling the file upload the Selenium Grid node and the clear argument are new in
SeleniumLibrary 4.0
Arguments
text <str>
action = ACCEPT <str>
timeout = None <timedelta> or <None>
Documentation
The alert is accepted by default, but that behavior can be controlled by using the
action argument same way as with Handle Alert.
timeout specifies how long to wait for the alert to appear. If it is not given, the
global default timeout is used instead.
Arguments
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 32/65
3/13/23, 1:57 AM SeleniumLibrary
It is possible to give expected options both as visible labels and as values. Starting
from SeleniumLibrary 3.0, mixing labels and values is not possible. Order of the
selected options is not validated.
If no expected options are given, validates that the list has no selections. A more
explicit alternative is using List Should Have No Selections.
See the Locating elements section for details about the locator syntax.
Examples:
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
Location Should Be
Arguments
url <str>
message = None <str> or <None>
Documentation
The url argument contains the exact url that should exist in browser.
The message argument can be used to override the default error message.
Arguments
expected <str>
message = None <str> or <None>
Documentation
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 33/65
3/13/23, 1:57 AM SeleniumLibrary
The message argument can be used to override the default error message.
Log Location
Documentation
Log Source
Arguments
Documentation
Logs and returns the HTML source of the current page or frame.
The loglevel argument defines the used log level. Valid log levels are WARN ,
INFO (default), DEBUG , TRACE and NONE (no logging).
Log Title
Documentation
Documentation
Mouse Down
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 34/65
3/13/23, 1:57 AM SeleniumLibrary
See also the more specific keywords Mouse Down On Image and Mouse Down On Link.
SeleniumLibrary
Arguments
Documentation
See the Locating elements section for details about the locator syntax. When using the
default locator strategy, images are searched using id , name , src and alt .
Arguments
Documentation
See the Locating elements section for details about the locator syntax. When using the
default locator strategy, links are searched using id , name , href and the link text.
Mouse Out
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
Mouse Over
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
Mouse Up
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 35/65
3/13/23, 1:57 AM SeleniumLibrary
SeleniumLibrary Arguments
Documentation
See the Locating elements section for details about the locator syntax.
Open Browser
Arguments
Documentation
The browser argument specifies which browser to use. The supported browsers are
listed in the table below. The browser names are case-insensitive and some browsers
have multiple supported names.
Browser Name(s)
Firefox firefox, ff
Google Chrome googlechrome, chrome, gc
Headless Firefox headlessfirefox
Headless Chrome headlesschrome
Internet Explorer internetexplorer, ie
Edge edge
Safari safari
Opera opera
Android android
Iphone iphone
PhantomJS phantomjs
HTMLUnit htmlunit
HTMLUnit with Javascript htmlunitwithjs
To be able to actually use one of these browsers, you need to have a matching
Selenium browser driver available. See the project documentation for more details.
Headless Firefox and Headless Chrome are new additions in SeleniumLibrary 3.1.0 and
require Selenium 3.8.0 or newer.
After opening the browser, it is possible to use optional url to navigate the browser
to the desired address.
Optional alias is an alias given for this browser instance and it can be used for
switching between browsers. When same alias is given with two Open Browser
keywords, the first keyword will open a new browser, but the second one will switch to
the already opened browser and will not open a new browser. The alias definition
overrules browser definition. When same alias is used but a different browser
is defined, then switch to a browser with same alias is done and new browser is not
opened. An alternative approach for switching is using an index returned by this
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 36/65
3/13/23, 1:57 AM SeleniumLibrary
keyword. These indices start from 1, are incremented when new browsers are opened,
and reset back to 1 when Close All Browsers is called. See Switch Browser for more
SeleniumLibrary information and examples.
Optional ff_profile_dir is the path to the Firefox profile directory if you wish to
overwrite the default profile Selenium uses. Notice that prior to SeleniumLibrary 3.0,
the library contained its own profile that was used by default. The
ff_profile_dir can also be an instance of the selenium.webdriver.FirefoxProfile .
As a third option, it is possible to use FirefoxProfile methods and attributes to define
the profile using methods and attributes in the same way as with options argument.
Example: It is possible to use FirefoxProfile set_preference to define different profile
settings. See options argument documentation in below how to handle backslash
escaping.
The string format allows defining Selenium options methods or attributes and their
arguments in Robot Framework test data. The method and attributes names are case
and space sensitive and must match to the Selenium options methods and attributes
names. When defining a method, it must be defined in a similar way as in python:
method name, opening parenthesis, zero to many arguments and closing parenthesis.
If there is a need to define multiple arguments for a single method, arguments must
be separated with comma, just like in Python. Example: add_argument("--headless") or
add_experimental_option("key", "value"). Attributes are defined in a similar way as in
Python: attribute name, equal sign, and attribute value. Example, headless=True.
Multiple methods and attributes must be separated by a semicolon. Example:
add_argument("--headless");add_argument("--start-maximized").
Arguments allow defining Python data types and arguments are evaluated by using
Python ast.literal_eval. Strings must be quoted with single or double quotes, example
"value" or 'value'. It is also possible to define other Python builtin data types, example
True or None, by not using quotes around the arguments.
The string format is space friendly. Usually, spaces do not alter the defining methods
or attributes. There are two exceptions. In some Robot Framework test data formats,
two or more spaces are considered as cell separator and instead of defining a single
argument, two or more arguments may be defined. Spaces in string arguments are not
removed and are left as is. Example add_argument ( "--headless" ) is same as
add_argument("--headless"). But add_argument(" --headless ") is not same same as
add_argument ( "--headless" ), because spaces inside of quotes are not removed. Please
note that if options string contains backslash, example a Windows OS path, the
backslash needs escaping both in Robot Framework data and in Python side. This
means single backslash must be writen using four backslash characters. Example,
Windows path: "C:\path\to\profile" must be written as "C:\\\\path\\\to\\\\profile".
Another way to write backslash is use Python raw strings and example write:
r"C:\\path\\to\\profile".
As last format, options argument also supports receiving the Selenium options as
Python class instance. In this case, the instance is used as-is and the SeleniumLibrary
will not convert the instance to other formats. For example, if the following code return
value is saved to ${options} variable in the Robot Framework data:
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 37/65
3/13/23, 1:57 AM SeleniumLibrary
options = webdriver.ChromeOptions()
options.add_argument('--disable-dev-shm-usage')
SeleniumLibrary return options
Optional service_log_path argument defines the name of the file where to write
the browser driver logs. If the service_log_path argument contain a marker
{index} , it will be automatically replaced with unique running index preventing files
to be overwritten. Indices start's from 1, and how they are represented can be
customized using Python's format string syntax.
Examples:
Alias examples:
# Opens new
${1_index} Open
http://example.com Chrome alias=Chrome browser because
= Browser
alias is new.
# Opens new
${2_index} Open
http://example.com Firefox browser because
= Browser
alias is not defined.
# Switches to the
${3_index} Open
http://example.com Chrome alias=Chrome browser with
= Browser
Chrome alias.
# Switches to the
${4_index} Open
http://example.com Chrome alias=${1_index} browser with
= Browser
Chrome alias.
Should Be
${1_index} ${3_index}
Equal
Should Be
${1_index} ${4_index}
Equal
Should Be
${2_index} ${2}
Equal
Open options=add_argument("--disable-popup-blocking");
http://example.com Chrome
Browser add_argument("--ignore-certificate-errors")
${options}
Get Options
=
Open
http://example.com Chrome options=${options}
Browser
Open options=binary_location="/path/to/binary";add_argum
None Chrome
Browser debugging-port=port")
Open
None Chrome options=binary_location=r"C:\\path\\to\\binary"
Browser
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 38/65
3/13/23, 1:57 AM SeleniumLibrary
disk.
# Using
SeleniumLibrary
Open
http://example.com Firefox ff_profile_dir=${FirefoxProfile_instance} instance of
Browser
FirefoxProfile.
# Defining
ff_profile_dir=set_preference("key",
Open profile using
http://example.com Firefox "value");set_preference("other",
Browser FirefoxProfile
"setting")
mehtods.
If the provided configuration options are not enough, it is possible to use Create
Webdriver to customize browser initialization even more.
Using alias to decide, is the new browser opened is new in SeleniumLibrary 4.0. The
options and service_log_path are new in SeleniumLibrary 4.0. Support for
ff_profile_dir accepting an instance of the selenium.webdriver.FirefoxProfile and
support defining FirefoxProfile with methods and attributes are new in SeleniumLibrary
4.0.
Arguments
Documentation
Arguments
text <str>
loglevel = TRACE <str>
Documentation
If this keyword fails, it automatically logs the page source using the log level specified
with the optional loglevel argument. Valid log levels are DEBUG , INFO (default),
WARN , and NONE . If the log level is NONE or below the current active log level the
source will not be logged.
Arguments
Documentation
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 39/65
3/13/23, 1:57 AM SeleniumLibrary
SeleniumLibrary See Page Should Contain Element for an explanation about message and
loglevel arguments.
See the Locating elements section for details about the locator syntax. When using the
default locator strategy, buttons are searched using id , name , and value .
Arguments
Documentation
See Page Should Contain Element for an explanation about message and
loglevel arguments.
See the Locating elements section for details about the locator syntax.
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
The message argument can be used to override the default error message.
The limit argument can used to define how many elements the page should
contain. When limit is None (default) page can contain one or more elements.
When limit is a number, page must contain same number of elements.
See Page Should Contain for an explanation about the loglevel argument.
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 40/65
3/13/23, 1:57 AM SeleniumLibrary
Arguments
SeleniumLibrary
locator <WebElement> or <str>
message = None <str> or <None>
loglevel = TRACE <str>
Documentation
See the Locating elements section for details about the locator syntax. When using the
default locator strategy, images are searched using id , name , src and alt .
See Page Should Contain Element for an explanation about message and
loglevel arguments.
Arguments
Documentation
See the Locating elements section for details about the locator syntax. When using the
default locator strategy, links are searched using id , name , href and the link text.
See Page Should Contain Element for an explanation about message and
loglevel arguments.
Arguments
Documentation
See Page Should Contain Element for an explanation about message and
loglevel arguments.
See the Locating elements section for details about the locator syntax.
Arguments
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 41/65
3/13/23, 1:57 AM SeleniumLibrary
Documentation
See Page Should Contain Element for an explanation about message and
loglevel arguments.
See the Locating elements section for details about the locator syntax. When using the
default locator strategy, radio buttons are searched using id , name and value .
Arguments
Documentation
See Page Should Contain Element for an explanation about message and
loglevel arguments.
See the Locating elements section for details about the locator syntax.
Arguments
text <str>
loglevel = TRACE <str>
Documentation
See Page Should Contain for an explanation about the loglevel argument.
Arguments
Documentation
See Page Should Contain Element for an explanation about message and
loglevel arguments.
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 42/65
3/13/23, 1:57 AM SeleniumLibrary
See the Locating elements section for details about the locator syntax. When using the
default locator strategy, buttons are searched using id , name , and value .
SeleniumLibrary
Arguments
Documentation
See Page Should Contain Element for an explanation about message and
loglevel arguments.
See the Locating elements section for details about the locator syntax.
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
See Page Should Contain for an explanation about message and loglevel
arguments.
Arguments
Documentation
See the Locating elements section for details about the locator syntax. When using the
default locator strategy, images are searched using id , name , src and alt .
See Page Should Contain Element for an explanation about message and
loglevel arguments.
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 43/65
3/13/23, 1:57 AM SeleniumLibrary
Documentation
See the Locating elements section for details about the locator syntax. When using the
default locator strategy, links are searched using id , name , href and the link text.
See Page Should Contain Element for an explanation about message and
loglevel arguments.
Arguments
Documentation
See Page Should Contain Element for an explanation about message and
loglevel arguments.
See the Locating elements section for details about the locator syntax.
Arguments
Documentation
See Page Should Contain Element for an explanation about message and
loglevel arguments.
See the Locating elements section for details about the locator syntax. When using the
default locator strategy, radio buttons are searched using id , name and value .
Arguments
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 44/65
3/13/23, 1:57 AM SeleniumLibrary
Documentation
See Page Should Contain Element for an explanation about message and
loglevel arguments.
See the Locating elements section for details about the locator syntax.
Press Key
Arguments
Documentation
Press Keys
Arguments
Documentation
If locator evaluates as false, see Boolean arguments for more details, then the
keys are sent to the currently active browser. Otherwise element is searched and
keys are send to the element identified by the locator . In later case, keyword fails
if element is not found. See the Locating elements section for details about the locator
syntax.
keys arguments can contain one or many strings, but it can not be empty. keys can
also be a combination of Selenium Keys and strings or a single Selenium Key. If
Selenium Key is combined with strings, Selenium key and strings must be separated by
the + character, like in CONTROL+c. Selenium Keys are space and case sensitive and
Selenium Keys are not parsed inside of the string. Example AALTO, would send string
AALTO and ALT not parsed inside of the string. But A+ALT+O would found Selenium
ALT key from the keys argument. It also possible to press many Selenium Keys down
at the same time, example 'ALT+ARROW_DOWN`.
If Selenium Keys are detected in the keys argument, keyword will press the Selenium
Key down, send the strings and then release the Selenium Key. If keyword needs to
send a Selenium Key as a string, then each character must be separated with +
character, example E+N+D.
CTRL is alias for Selenium CONTROL and ESC is alias for Selenium ESCAPE
Examples:
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 45/65
3/13/23, 1:57 AM SeleniumLibrary
Press
text_field AAAAA # Sends string "AAAAA" to element.
Keys
SeleniumLibrary Press
Keys
None BBBBB
# Sends string "BBBBB" to currently
active browser.
Press
text_field E+N+D # Sends string "END" to element.
Keys
Press # Sends strings "XXX" and "YY" to
text_field XXX YY
Keys element.
Press
text_field XXX+YY # Same as above.
Keys
# Pressing "ALT" key down, then
Press
text_field ALT+ARROW_DOWN pressing ARROW_DOWN and then
Keys
releasing both keys.
Press # Pressing "ALT" key and then
text_field ALT ARROW_DOWN
Keys pressing ARROW_DOWN.
# Pressing CTRL key down, sends
Press
text_field CTRL+c string "c" and then releases CTRL
Keys
key.
Press
button RETURN # Pressing "ENTER" key to element.
Keys
Arguments
group_name <str>
value <str>
Documentation
Arguments
group_name <str>
Documentation
Arguments
Documentation
The initial keyword to use is set when importing the library, and the keyword that is
used by default is Capture Page Screenshot. Taking a screenshot when something failed
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 46/65
3/13/23, 1:57 AM SeleniumLibrary
is a very useful feature, but notice that it can slow down the execution.
This keyword returns the name of the previously registered failure keyword or Python
None if this functionality was previously disabled. The return value can be always used
to restore the original value later.
Example:
Reload Page
Documentation
Arguments
strategy_name <str>
Documentation
See Custom locators for information on how to create and use custom strategies.
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 47/65
3/13/23, 1:57 AM SeleniumLibrary
Arguments
SeleniumLibrary
locator <WebElement> or <str>
Documentation
See the Locating elements section for details about the locator syntax.
Select Checkbox
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
Select Frame
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
Works both with frames and iframes. Use Unselect Frame to cancel the frame selection
and return to the main frame.
Example:
Arguments
Documentation
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 48/65
3/13/23, 1:57 AM SeleniumLibrary
If more than one option is given for a single-selection list, the last value will be
selected. With multi-selection lists all specified options are selected, but possible old
SeleniumLibrary selections are not cleared.
See the Locating elements section for details about the locator syntax.
Arguments
Documentation
If more than one option is given for a single-selection list, the last value will be
selected. With multi-selection lists all specified options are selected, but possible old
selections are not cleared.
See the Locating elements section for details about the locator syntax.
Arguments
Documentation
If more than one option is given for a single-selection list, the last value will be
selected. With multi-selection lists all specified options are selected, but possible old
selections are not cleared.
See the Locating elements section for details about the locator syntax.
Arguments
group_name <str>
value <str>
Documentation
Examples:
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 49/65
3/13/23, 1:57 AM SeleniumLibrary
Select Radio Button contact email
SeleniumLibrary
Set Browser Implicit Wait
Arguments
value <timedelta>
Documentation
Same as Set Selenium Implicit Wait but only affects the current browser.
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
Arguments
Documentation
path argument specifies the absolute path to a directory where the screenshots
should be written to. If the directory does not exist, it will be created. The directory can
also be set when importing the library. If it is not configured anywhere, screenshots are
saved to the same directory where Robot Framework's log file is written.
If path equals to EMBED (case insensitive) and Capture Page Screenshot or capture
Element Screenshot keywords filename argument is not changed from the default
value, then the page or element screenshot is embedded as Base64 image to the
log.html.
The previous value is returned and can be used to restore the original value later if
needed.
Returning the previous value is new in SeleniumLibrary 3.0. The persist argument was
removed in SeleniumLibrary 3.2 and EMBED is new in SeleniumLibrary 4.2.
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 50/65
3/13/23, 1:57 AM SeleniumLibrary
Arguments
SeleniumLibrary
value <timedelta>
Documentation
This keyword sets the implicit wait for all opened browsers. Use Set Browser Implicit
Wait to set it only to the current browser.
Example:
Arguments
value <timedelta>
Documentation
Example:
Arguments
value <timedelta>
Documentation
Example:
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 51/65
3/13/23, 1:57 AM SeleniumLibrary
Set Selenium Timeout ${orig timeout}
SeleniumLibrary
Set Window Position
Arguments
x <int>
y <int>
Documentation
The position is relative to the top left corner of the screen, but some browsers exclude
possible task bar set by the operating system from the calculation. The actual position
may thus be different with different browsers.
Values can be given using strings containing numbers or by using actual numbers. See
also Get Window Position.
Example:
Arguments
width <int>
height <int>
inner = False <bool>
Documentation
Values can be given using strings containing numbers or by using actual numbers. See
also Get Window Size.
Browsers have a limit on their minimum size. Trying to set them smaller will cause the
actual size to be bigger than the requested size.
If inner parameter is set to True, keyword sets the necessary window width and
height to have the desired HTML DOM window.innerWidth and window.innerHeight.
See Boolean arguments for more details on how to set boolean arguments.
This inner argument does not support Frames. If a frame is selected, switch to
default before running this.
Example:
Simulate Event
Arguments
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 52/65
3/13/23, 1:57 AM SeleniumLibrary
This keyword is useful if element has OnEvent handler that needs to be explicitly
invoked.
See the Locating elements section for details about the locator syntax.
Submit Form
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
Switch Browser
Arguments
index_or_alias <str>
Documentation
Indices are returned by the Open Browser keyword and aliases can be given to it
explicitly. Indices start from 1.
Example:
Above example expects that there was no other open browsers when opening the first
one because it used index 1 when switching to it later. If you are not sure about that,
you can store the index into a variable as below.
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 53/65
3/13/23, 1:57 AM SeleniumLibrary
Switch Window
SeleniumLibrary
Arguments
Documentation
If the window is found, all subsequent commands use the selected window, until this
keyword is used again. If the window is not found, this keyword fails. The previous
windows handle is returned and can be used to switch back to it later.
Notice that alerts should be handled with Handle Alert or other alert related keywords.
The locator can be specified using different strategies somewhat similarly as when
locating elements on pages.
The timeout is used to specify how long keyword will poll to select the new window.
The timeout is new in SeleniumLibrary 3.2.
Example:
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 54/65
3/13/23, 1:57 AM SeleniumLibrary
NOTE:
Arguments
Documentation
See Get Table Cell that this keyword uses internally for an explanation about accepted
arguments.
Arguments
Documentation
The table is located using the locator argument and its column found using
column . See the Locating elements section for details about the locator syntax.
Column indexes start from 1. It is possible to refer to columns from the end by using
negative indexes so that -1 is the last column, -2 is the second last, and so on.
If a table contains cells that span multiple columns, those merged cells count as a
single column.
See Page Should Contain Element for an explanation about the loglevel argument.
Arguments
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 55/65
3/13/23, 1:57 AM SeleniumLibrary
Documentation
Any <td> element inside <tfoot> element is considered to be part of the footer.
The table is located using the locator argument. See the Locating elements section
for details about the locator syntax.
See Page Should Contain Element for an explanation about the loglevel argument.
Arguments
Documentation
Any <th> element anywhere in the table is considered to be part of the header.
The table is located using the locator argument. See the Locating elements section
for details about the locator syntax.
See Page Should Contain Element for an explanation about the loglevel argument.
Arguments
Documentation
The table is located using the locator argument and its column found using
column . See the Locating elements section for details about the locator syntax.
Row indexes start from 1. It is possible to refer to rows from the end by using negative
indexes so that -1 is the last row, -2 is the second last, and so on.
If a table contains cells that span multiple rows, a match only occurs for the uppermost
row of those merged cells.
See Page Should Contain Element for an explanation about the loglevel argument.
SeleniumLibrary Arguments
Documentation
The table is located using the locator argument. See the Locating elements section
for details about the locator syntax.
See Page Should Contain Element for an explanation about the loglevel argument.
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
Arguments
Documentation
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 57/65
3/13/23, 1:57 AM SeleniumLibrary
See the Locating elements section for details about the locator syntax.
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
Title Should Be
Arguments
title <str>
message = None <str> or <None>
Documentation
The message argument can be used to override the default error message.
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
Unselect Checkbox
Arguments
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 58/65
3/13/23, 1:57 AM SeleniumLibrary
SeleniumLibrary Documentation
See the Locating elements section for details about the locator syntax.
Unselect Frame
Documentation
Arguments
Documentation
Indexes of list options start from 0. This keyword works only with multi-selection lists.
See the Locating elements section for details about the locator syntax.
Arguments
Documentation
See the Locating elements section for details about the locator syntax.
Arguments
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 59/65
3/13/23, 1:57 AM SeleniumLibrary
Documentation
See the Locating elements section for details about the locator syntax.
Arguments
condition <str>
timeout = None <timedelta> or <None>
error = None <str> or <None>
Documentation
The condition can be arbitrary JavaScript expression but it must return a value to be
evaluated. See Execute JavaScript for information about accessing content on pages.
Fails if the timeout expires before the condition becomes true. See the Timeouts
section for more information about using timeouts and their default value.
Examples:
Wait For
return document.title == "New Title"
Condition
Wait For
return jQuery.active == 0
Condition
Wait For style = document.querySelector('h1').style; return style.background == "red"
Condition && style.color == "white"
Arguments
Documentation
Fails if timeout expires before the text appears. See the Timeouts section for more
information about using timeouts and their default value and the Locating elements
section for details about the locator syntax.
Arguments
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 60/65
3/13/23, 1:57 AM SeleniumLibrary
Documentation
Fails if timeout expires before the text disappears. See the Timeouts section for
more information about using timeouts and their default value and the Locating
elements section for details about the locator syntax.
Arguments
Documentation
Fails if timeout expires before the element is enabled. See the Timeouts section for
more information about using timeouts and their default value and the Locating
elements section for details about the locator syntax.
Arguments
Documentation
Fails if timeout expires before the element is not visible. See the Timeouts section
for more information about using timeouts and their default value and the Locating
elements section for details about the locator syntax.
Arguments
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 61/65
3/13/23, 1:57 AM SeleniumLibrary
Documentation
Fails if timeout expires before the element is visible. See the Timeouts section for
more information about using timeouts and their default value and the Locating
elements section for details about the locator syntax.
Arguments
expected <str>
timeout = None <timedelta> or <None>
message = None <str> or <None>
Documentation
Fails if timeout expires before the ___location contains. See the Timeouts section for
more information about using timeouts and their default value.
The message argument can be used to override the default error message.
Arguments
___location <str>
timeout = None <timedelta> or <None>
message = None <str> or <None>
Documentation
Fails if timeout expires before the ___location not contains. See the Timeouts section
for more information about using timeouts and their default value.
The message argument can be used to override the default error message.
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 62/65
3/13/23, 1:57 AM SeleniumLibrary
Arguments
SeleniumLibrary
expected <str>
timeout = None <timedelta> or <None>
message = None <str> or <None>
Documentation
Fails if timeout expires before the ___location is. See the Timeouts section for more
information about using timeouts and their default value.
The message argument can be used to override the default error message.
Arguments
___location <str>
timeout = None <timedelta> or <None>
message = None <str> or <None>
Documentation
Fails if timeout expires before the ___location is not. See the Timeouts section for more
information about using timeouts and their default value.
The message argument can be used to override the default error message.
Arguments
text <str>
timeout = None <timedelta> or <None>
error = None <str> or <None>
Documentation
Fails if timeout expires before the text appears. See the Timeouts section for more
information about using timeouts and their default value.
SeleniumLibrary Arguments
Documentation
Fails if timeout expires before the element appears. See the Timeouts section for
more information about using timeouts and their default value and the Locating
elements section for details about the locator syntax.
The limit argument can used to define how many elements the page should
contain. When limit is None (default) page can contain one or more elements.
When limit is a number, page must contain same number of elements.
Arguments
text <str>
timeout = None <timedelta> or <None>
error = None <str> or <None>
Documentation
Fails if timeout expires before the text disappears. See the Timeouts section for
more information about using timeouts and their default value.
Arguments
Documentation
Waits until the element locator disappears from the current page.
Fails if timeout expires before the element disappears. See the Timeouts section for
more information about using timeouts and their default value and the Locating
elements section for details about the locator syntax.
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 64/65
3/13/23, 1:57 AM SeleniumLibrary
The limit argument can used to define how many elements the page should not
contain. When limit is None (default) page can`t contain any elements. When limit is
SeleniumLibrary a number, page must not contain same number of elements.
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html 65/65