SeleniumLibrary is a web testing library for Robot Test Automation Framework.
It uses the Selenium Remote Control tool internally to control a web browser. See http://selenium-rc.openqa.org/ for more information on Selenium tool.
SeleniumLibrary runs tests in a real browser instance. It should work in most modern browsers and can be used with both Python and Jython interpreters.
Before running the tests
Prior to running test cases using SeleniumLibrary, the Selenium Server must be started. This can be done using keyword Start Selenium Server or from the command line by using command: java -jar /path/to/selenium-server.jar. The Selenium Server is included in the SeleniumLibrary distribution and can be found under [PythonLibs]/site-packages/SeleniumLibrary/lib. Additionally, Open Browser keyword must be used in order to open browser in the desired location before any other keyword from the library may be used.
Locating elements
To do operations on elements, elements have to be identified. The most common way of doing this is by searching the values of key attributes of an element type. All keywords that operate on elements document the key attributes for that element type. If the given locator argument matches the value of any key attribute, the element is found.
Asterisk character may be used as a wildcard in locators, but it only works as the last character of the expression. In the middle of the locator it is interpreted as literal '*'.
It is also possible to give an arbitrary XPath or DOM expression as locator. In this case, the expression must be prefixed with either 'xpath=' or 'dom='.
Examples:
| Click Link | my link | # Matches if either link text or value of attribute 'id', 'name' or 'href' equals 'my link' |
| Page Should Contain Link | Link id * | # Passes if the page contain any link starting with 'Link id' |
| Select Checkbox | xpath=//table[0]/input[@name='my_checkbox'] | # Using XPath |
| Click Image | dom=document.images[56] | # Using a DOM expression |
| Table Should Contain | tableID | $ 43,00 |
| Table Should Contain | css=h2.someClass ~ table:last-child() | text |
| Click Link | link text | # A page is expected to load. | ||
| Click Link | another link | don't wait | # A page is not expected to load. | |
| Select Radio Button | group1 | value1 | # A page is not expected to load. | |
| Select Radio Button | group2 | value2 | and wait | # A page is expected to load. |
| Arguments | Documentation | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| timeout=5.0, server_host=localhost, server_port=4444, jar_path=None | SeleniumLibrary can be imported with optional arguments. timeout is the default timeout used to wait for page load actions. It can be later set with Set Selenium Timeout host and port are used to connect to Selenium Server. Browsers opened with this SeleniumLibrary instance will be attached to that server. Note that the Selenium Server must be running before Open Browser keyword can be used. Selenium Server can be started with keyword Start Selenium Server. jar_path is the absolute path to the selenium-server.jar file to be used by the library. If set, a custom, modified version can be started instead of the default one distributed with the library. Examples:
|
| Keyword | Arguments | Documentation | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Add Location Strategy | strategy_name, function_definition | Adds a custom location strategy. strategy_name is the name of the strategy; a prefix used when addressing an element. function_definition is the JavaScript that will be called. It must return a DOM reference, an array with DOM references, or null. Together with the modified selenium-server.jar it can provide a new method of locating elements on the page. For example, a jQuery strategy can be added to locate elements given jQuery selector syntax. For jQuery selector setup see: http://code.google.com/p/robotframework-seleniumlibrary/wiki/jQueryElementSelectors Examples:
|
||||||||||||||||||||||||||||||||||||||||||||||||
| Alert Should Be Present | text= | Verifies an alert is present and dismisses it. If text is a non-empty string, then it is also verified that the message of the alert equals to text. Will fail if no alert is present. Note that when running tests with selenium, the alerts will not be visible in the browser. Nevertheless, following keywords will fail unless the alert is dismissed by this keyword or by Get Alert Message. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Call Selenium Api | method_name, *args | Calls a method in the Selenium remote control API directly. This keyword can be used if some functionality provided by Selenium is not yet exposed as a keyword. method_name is the name of the method to call in the Selenium API and args specify the arguments it expects. The keyword first tries to find a method in Selenium's Python API provided by the selenium.py file. If no matching method is found, the keyword calls the Selenium Server's Remote Controller API directly via the do_command method in the Python API [1]. In both cases the keyword returns the return value of the call directly without any modifications or verifications. Examples:
[1] http://release.seleniumhq.org/selenium-remote-control/1.0-beta-2/doc/python/ |
||||||||||||||||||||||||||||||||||||||||||||||||
| Capture Page Screenshot | filename=None, css=background=#CCFFDD | Takes a screenshot of the current page and embeds it into the log. filename argument specifies the name of the file to write the screenshot into. It works the same was as with Capture Screenshot. css can be used to modify how the screenshot is taken. By default the bakground color is changed to avoid possible problems with background leaking when the page layout is somehow broken. Selenium currently supports this keyword out-of-the-box only with Firefox browser. To make it work with IE, you can start the Selenium Server with -singleWindow option and use *ieproxy as the browser. Additionally, the browser independent Capture Screenshot keyword can be used instead. This keyword was added in SeleniumLibrary 2.3. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Capture Screenshot | filename=None | Takes a screenshot of the entire screen and embeds it into the log. If no filename is given, the screenshot is saved into file selenium-screenshot-<counter>.png under the directory where the Robot Framework log file is written into. The filename is also considered relative to the same directory, if it is not given in absolute format. When running on a locked Windows machine, the resulting screenshots will be all black. A workaround is using the Capture Page Screenshot keyword instead. There were some changes to this keyword in the 2.3 release: - Possibility to take screenshots also when the Selenium Server is running on a remote machine was added. - Support for absolute filename paths was added. - Automatic creation of intermediate directories in the path where the screenshot is saved was removed. OperatingSystem.Create Directory can be used instead. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Checkbox Should Be Selected | locator | Verifies checkbox identified by locator is selected/checked. Key attributes for checkboxes are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Checkbox Should Not Be Selected | locator | Verifies checkbox identified by locator is not selected/checked. Key attributes for checkboxes are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Choose Cancel On Next Confirmation | Cancel will be selected the next time Confirm Action is used. | |||||||||||||||||||||||||||||||||||||||||||||||||
| Choose File | identifier, file_path | Inputs the file_path into file input field found by identifier. This keyword is most often used to input files into upload forms. In normal usage the file specified with file_path must be available on the samme host where the Selenium Server is running. An alternative usage is specifying the file_path with an URL (starting with http:// or https://) in which case the file will be downloaded automatically. The limitations of this method are that it only works on Firefox and the file must be placed at the root level of a web server. Example:
The support for remote files was added in SeleniumLibrary 2.3.2. It uses Selenium's attach_file method which is explained at http://saucelabs.com/blog/index.php/2009/11/selenium-tip-of-the-week-upload-files-on-browsers-running-over-remote-machines/ |
||||||||||||||||||||||||||||||||||||||||||||||||
| Click Button | locator, dont_wait= | Clicks a button identified by locator. Key attributes for buttons are id, name and value. See introduction for details about locating elements and about meaning of dont_wait argument. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Click Element | locator, dont_wait= | Click element identified by locator. Key attributes for arbitrary elements are id and name. See introduction for details about locating elements and about meaning of dont_wait argument. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Click Image | locator, dont_wait= | Clicks an image found by locator. Key attributes for images are id, src and alt. See introduction for details about locating elements and about meaning of dont_wait argument. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Click Link | locator, dont_wait= | Clicks a link identified by locator. Key attributes for links are id, name, href and link text. See introduction for details about locating elements and about meaning of dont_wait argument. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Close All Browsers | Closes all open browsers and empties the connection cache. After this keyword new indexes get 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 | Closes the current browser. | |||||||||||||||||||||||||||||||||||||||||||||||||
| Close Window | Closes currently opened pop-up window. | |||||||||||||||||||||||||||||||||||||||||||||||||
| Confirm Action | Dismisses currently shown confirmation dialog. By default, this keyword chooses 'Ok' option from the dialog. If 'cancel' needs to be chosen, keyword Choose Cancel On Next Confirmation must be called before the action that causes the confirmation dialog to be shown. Examples:
|
|||||||||||||||||||||||||||||||||||||||||||||||||
| Current Frame Contains | text, level=INFO | Verifies that current page contains text. If this keyword fails, it automatically logs the page source using the log level specified with the optional level argument. This argument was added in SeleniumLibrary 2.3.1. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Current Frame Should Contain | text, level=INFO | Verifies that current page contains text. If this keyword fails, it automatically logs the page source using the log level specified with the optional level argument. This argument was added in SeleniumLibrary 2.3.1. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Delete All Cookies | Deletes all cookies by calling Delete Cookie repeatedly. | |||||||||||||||||||||||||||||||||||||||||||||||||
| Delete Cookie | name, options= | Deletes cookie matching name and options. If the cookie is not found, nothing happens. options is the options for the cookie as a string. Currently supported options include 'path', 'domain' and 'recurse.' Format for options is "path=/path/, domain=.foo.com, recurse=true". The order of options is irrelevant. Note that specifying a domain that isn't a subset of the current domain will usually fail. Setting recurse=true will cause this keyword to search all sub-domains of current domain with all paths that are subset of current path. This can take a long time. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Drag And Drop | locator, movement | Drags element identified with locator by movement `movement is a string in format "+70 -300" interpreted as pixels in relation to elements current position. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Element Should Contain | locator, excepted, message= | Verifies element identified by locator contains text expected. message can be used to override the default error message. Key attributes for arbitrary elements are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Execute Javascript | *code | Executes the given JavaScript code. *code may contain multiple statements and the return value of last statement is returned by this keyword. *code may be divided in multiple cells in the test data. In that case, the parts are catenated as is with no white space added. Note that, by default, the code will be executed in the context of the Selenium object itself, so 'this' will refer to the Selenium object. Use 'window' to refer to the window of your application, e.g. window.document.getElementById('foo') Example:
|
||||||||||||||||||||||||||||||||||||||||||||||||
| Focus | locator | Sets focus to element identified by locator. This is useful for instance to direct native keystrokes to particular element using Press Key Native. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Frame Should Contain | locator, text | Verifies frame identified by locator contains text. Key attributes for frames are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Frame Should Contain Text | locator, text | Verifies frame identified by locator contains text. Key attributes for frames are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Get Alert Message | Returns the text of current JavaScript alert. This keyword will fail if no alert is present. Note that when running tests with selenium, the alerts will not be visible in the browser. Nevertheless, following keywords will fail unless the alert is dismissed by this keyword or by Alert Should Be Present. |
|||||||||||||||||||||||||||||||||||||||||||||||||
| Get All Links | Returns a list containing ids of all links found in current page. If a link has no id, an empty string will be in the list instead. |
|||||||||||||||||||||||||||||||||||||||||||||||||
| Get Cookie Value | name | Returns value of cookie found with name. If no cookie is found with name, this keyword fails. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Get Cookies | Returns all cookies of the current page. | |||||||||||||||||||||||||||||||||||||||||||||||||
| Get Element Attribute | attribute_locator | Return value of element attribute. attribute_locator consists of element locator followed by an @ sign and attribute name, for example "element_id@class". |
||||||||||||||||||||||||||||||||||||||||||||||||
| Get Horizontal Position | locator | Returns horizontal position of element identified by locator. The position is returned in pixels off the left side of the page, as an integer. Fails if a matching element is not found. See also Get Vertical Position. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Get Location | Returns the current location. | |||||||||||||||||||||||||||||||||||||||||||||||||
| Get Matching Xpath Count | xpath | Returns number of elements matching xpath | ||||||||||||||||||||||||||||||||||||||||||||||||
| Get Source | Returns the entire html source of the current page or frame. | |||||||||||||||||||||||||||||||||||||||||||||||||
| Get Table Cell | table_locator, row, column | Returns the content from a table cell. Row and Column number start from 1. Header and footer rows are included in the count. This means that also cell content from header or footer rows can be obtained with this keyword. To understand how tables are identified, please take a look at the introduction. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Get Text | locator | Returns the text of element identified by locator. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Get Title | Returns title of current page. | |||||||||||||||||||||||||||||||||||||||||||||||||
| Get Value | locator | Returns the value attribute of element identified by locator. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Get Vertical Position | locator | Returns vertical position of element identified by locator. The position is returned in pixels off the top of the page, as an integer. Fails if a matching element is not found. See also Get Horizontal Position. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Get Window Identifiers | Returns values of id attributes of all windows known to the browser. | |||||||||||||||||||||||||||||||||||||||||||||||||
| Get Window Names | Returns names of all windows known to the browser. | |||||||||||||||||||||||||||||||||||||||||||||||||
| Get Window Titles | Returns titles of all windows known to the browser. | |||||||||||||||||||||||||||||||||||||||||||||||||
| Go Back | dont_wait= | Simulates the user clicking the "back" button on their browser. See introduction for details about locating elements and about meaning of dont_wait argument. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Go To | url | Navigates the active browser instance to the provided URL. | ||||||||||||||||||||||||||||||||||||||||||||||||
| Input Password | locator, text | Types the given password into text field identified by locator. Difference between this keyword and Input Text is that this keyword does not log the given password. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Input Text | locator, text | Types the given text into text field identified by locator. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| List Selection Should Be | locator, *values | Verifies the selection of list identified by locator is exactly *values. If you want to test that no option is selected, simply give no values. Key attributes for list are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| List Should Have No Selections | locator | Verifies list identified by locator has no selections. Key attributes for list are id and name. See introduction for more details on key attributes and locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Location Should Be | url | Verifies that current URL is exactly url. | ||||||||||||||||||||||||||||||||||||||||||||||||
| Location Should Contain | expected | Verifies that current URL contains expected. | ||||||||||||||||||||||||||||||||||||||||||||||||
| Log Source | level=INFO | Logs and returns the entire html source of the current page or frame. level defines the log level. Valid log levels are 'WARN', 'INFO' (the default), 'DEBUG' and 'TRACE'. In case level is invalid, 'INFO' will be used. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Maximize Browser Window | Maximizes current browser window. | |||||||||||||||||||||||||||||||||||||||||||||||||
| Mouse Down On Image | locator | Simulates a mouse down event on an image. Key attributes for images are id, src and alt. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Mouse Down On Link | locator | Simulates a mouse down event on a link. Key attributes for links are id, name, href and link text. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Open Browser | url, browser=firefox, alias=None | Opens a new browser instance to given url. Possible already opened connections are cached. 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 example. Optional alias is a alias for the browser instance and it can be used for switching between browsers similarly as the index. See Switch Browser for more details about that. Possible values for browser are all the values supported by Selenium and some aliases that are defined for convenience. The table below lists all the supported browsers.
Additionally, a string like *custom /path/to/browser-executable can be used to specify the browser directly. In this case, the path needs to point to an executable, not a script, otherwise the library may not be able to shut down the browser properly. Note, that you will encounter strange behaviour, if you open multiple Internet Explorer browser instances. That's also why Switch Browser only works with one IE browser at most. http://selenium-grid.seleniumhq.org/faq.html#i_get_some_strange_errors_when_i_run_multiple_internet_explorer_instances_on_the_same_machine |
||||||||||||||||||||||||||||||||||||||||||||||||
| Open Context Menu | locator, offset=None | Opens context menu on element identified by locator. | ||||||||||||||||||||||||||||||||||||||||||||||||
| Page Should Contain | text, level=INFO | Verifies that current page contains text. If this keyword fails, it automatically logs the page source using the log level specified with the optional level argument. This argument was added in SeleniumLibrary 2.3.1. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Page Should Contain Button | locator, message= | Verifies button identified by locator is found from current page. message can be used to override default error message. Key attributes for buttons are id, name and value. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Page Should Contain Checkbox | locator, message= | Verifies checkbox identified by locator is found from current page. message can be used to override default error message. Key attributes for checkboxes are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Page Should Contain Element | locator, message= | Verifies element identified by locator is found from current page. message can be used to override default error message. Key attributes for arbitrary elements are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Page Should Contain Image | locator, message= | Verifies image identified by locator is found from current page. message can be used to override default error message. Key attributes for images are id, src and alt. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Page Should Contain Link | locator, message= | Verifies link identified by locator is found from current page. message can be used to override default error message. Key attributes for links are id, name, href and link text. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Page Should Contain List | locator, message= | Verifies list identified by locator is found from current page. message can be used to override default error message. Key attributes for lists are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Page Should Contain Radio Button | locator, message= | Verifies radio button identified by locator is found from current page. message can be used to override default error message. Key attributes for radio buttons are id, name and value. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Page Should Contain Textfield | locator, message= | Verifies text field identified by locator is found from current page. message can be used to override default error message. Key attributes for text fields are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Page Should Not Contain | text | Verifies the current page does not contain text. | ||||||||||||||||||||||||||||||||||||||||||||||||
| Page Should Not Contain Button | locator, message= | Verifies button identified by locator is not found from current page. message can be used to override default error message. Key attributes for buttons are id, name and value. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Page Should Not Contain Checkbox | locator, message= | Verifies checkbox identified by locator is not found from current page. message can be used to override default error message. Key attributes for checkboxes are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Page Should Not Contain Element | locator, message= | Verifies element identified by locator is not found from current page. message can be used to override default error message. Key attributes for arbitrary elements are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Page Should Not Contain Image | locator, message= | Verifies image identified by locator is not found from current page. message can be used to override default error message. Key attributes for images are id, src and alt. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Page Should Not Contain Link | locator, message= | Verifies link identified by locator is not found from current page. message can be used to override default error message. Key attributes for links are id, name, href and link text. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Page Should Not Contain List | locator, message= | Verifies list identified by locator is not found from current page. message can be used to override default error message. Key attributes for lists are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Page Should Not Contain Radio Button | locator, message= | Verifies radio button identified by locator is not found from current page. message can be used to override default error message. Key attributes for radio buttons are id, name and value. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Page Should Not Contain Textfield | locator, message= | Verifies text field identified by locator is not found from current page. message can be used to override default error message. Key attributes for text fields are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Press Key | locator, key, wait= | Simulates user pressing key on element identified by locator. key is either a single character, or a numerical ASCII code of the key lead by '\'. See introduction for details about wait argument. Examples:
Sometimes this keyword doesn't trigger the correct JavaScript event on the clicked element. In those cases Press Key Native can be used as a workaround. The selenium command key_press [1] that is used internally exposes some erratic behaviour [2], especially when used with the Internet Explorer. If don't get the expected results, try Press Key Native instead. [1] http://release.seleniumhq.org/selenium-remote-control/1.0-beta-2/doc/python/selenium.selenium-class.html#key_press [2] http://jira.openqa.org/browse/SRC-385 |
||||||||||||||||||||||||||||||||||||||||||||||||
| Press Key Native | keycode, wait= | Simulates user pressing key by sending an operating system keystroke. keycode corresponds to java.awt.event.KeyEvent constants, which can be found from http://java.sun.com/javase/6/docs/api/constant-values.html#java.awt.event.KeyEvent.CHAR_UNDEFINED The key press does not target a particular element. An element can be chosen by first using Focus keyword. See introduction for details about wait argument. Examples:
Notice that this keyword is very fragile and, for example, using the keyboard or mouse while tests are running often causes problems. It can be beneficial to bring the window to the front again with executing JavaScript:
|
||||||||||||||||||||||||||||||||||||||||||||||||
| Radio Button Should Be Set To | group_name, value | Verifies radio button group identified by group_name has its selection set to value. | ||||||||||||||||||||||||||||||||||||||||||||||||
| Radio Button Should Not Be Selected | group_name | Verifies radio button group identified by group_name has no selection. | ||||||||||||||||||||||||||||||||||||||||||||||||
| Select All From List | locator, wait= | Selects all values from multi-select list identified by id. Key attributes for list are id and name. See introduction for details about locating elements and about wait argument. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Select Checkbox | locator | Selects checkbox identified by locator. Does nothing if checkbox is already selected. Key attributes for checkboxes are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Select Frame | locator | Sets frame identified by locator as current frame. Key attributes for frames are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Select From List | locator, *values | Selects *values from list identified by locator If more than one value is given for a single-selection list, the last value will be selected. If the target list is a multi-selection list, and *values is an empty list, all values of the list will be selected. Key attributes for list are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Select Radio Button | group_name, value, wait= | Sets selection of radio button group identified by group_name to value. See introduction for details about wait argument. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Select Window | windowID=None | Selects the window found with windowID as the context of actions. If the window is found, all subsequent commands use that window, until this keyword is used again. If the window is not found, this keyword fails. windowID may be either the title of the window or the name of the window in the JavaScript code that creates it. Name is second argument passed to JavaScript function window.open(). In case of multiple windows with same identifier are found, the first one is selected. To select main window, the argument can be left empty, or name 'main' can be used. Example:
|
||||||||||||||||||||||||||||||||||||||||||||||||
| Set Selenium Speed | seconds | Sets the delay that is waited after each Selenium command. This is useful mainly in slowing down the test execution to be able to view the execution. seconds may be given in Robot Framework time format. Returns the previous speed value. Example:
|
||||||||||||||||||||||||||||||||||||||||||||||||
| Set Selenium Timeout | seconds | Sets the timeout used by various keywords. The keywords that expect a page load to happen will fail if the page does not load within the time specified with seconds. seconds may be given in Robot Framework time format and the default value is 5 seconds. Returns the previous timeout value. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Simulate | locator, event | Simulates event on component identified by locator. This keyword is useful if component has OnEvent handler that needs to be explicitly invoked. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Start Selenium Server | *params | Starts the Selenium Server provided with SeleniumLibrary. params can contain additional command line parameters given to the started Selenium Server. Starting from 2.3 version the server will use the port given in importing automatically. In older versions the port must be given in params. Examples:
All Selenium Server output is written into selenium_server_log.txt file in the same directory as the Robot Framework log file. If the test execution round starts and stops Selenium Server multiple times, it is best to open the server to different port each time. From 2.3 onwards, this is easiest done by importing the library with different parameters each time. NOTE: This keyword requires subprocess module which is available on Python/Jython 2.5 or newer. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Stop Selenium Server | Stops the selenium server (and closes all browsers). | |||||||||||||||||||||||||||||||||||||||||||||||||
| Submit Form | locator=, dont_wait= | Submits a form identified by locator. If locator is empty, first form in the page will be submitted. Key attributes for forms are id and name. See introduction for details about locating elements and about meaning of dont_wait argument. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Switch Browser | index_or_alias | Switches between active browsers using index or alias. Index is got from Open Browser and alias can be given to it. Examples:
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 aren't sure about that you can store the index into a variable as below.
|
||||||||||||||||||||||||||||||||||||||||||||||||
| Table Cell Should Contain | table_locator, row, column, expected_content | Verifies that a certain cell in a table contains the expected content. Row and Column number start from 1. This keyword passes if the specified cell contains the given content. If you want to test that the cell content matches exactly, or that it e.g. starts with some text, use Get Table Cell keyword in combination with built-in keywords such as Should Be Equal or Should Start With. To understand how tables are identified, please take a look at the introduction. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Table Column Should Contain | table_locator, col, expected_content | Verifies that a specific column contains the expected_content. The first leftmost column is column number 1. If the table contains cells that span multiple columns, those merged cells count as a single column. For example both tests below work, if in one row columns A and B are merged with colspan="2", and the logical third column contains "C". Example:
To understand how tables are identified, please take a look at the introduction. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Table Footer Should Contain | table_locator, expected_content | Verifies that the table footer contains the expected_content. With table footer can be described as any <td>-element that is child of a <tfoot>-element. To understand how tables are identified, please take a look at the introduction. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Table Header Should Contain | table_locator, expected_content | Verifies that the table header, i.e. any <th>...</th> element, contains the expected_content. To understand how tables are identified, please take a look at the introduction. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Table Row Should Contain | table_locator, row, expected_content | Verifies that a specific table row contains the expected_content. The uppermost row is row number 1. For tables that are structured with thead, tbody and tfoot, only the tbody section is searched. Please use Table Header Should Contain or Table Footer Should Contain for tests against the header or footer content. If the table contains cells that span multiple rows, a match only occurs for the uppermost row of those merged cells. To understand how tables are identified, please take a look at the introduction. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Table Should Contain | table_locator, expected_content | Verifies that the expected content can be found somewhere in the table. To understand how tables are identified, please take a look at the introduction. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Text Field Should Contain | locator, expected, message= | Verifies text field identified by locator contains text expected. message can be used to override default error message. Key attributes for text fields are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Textfield Value Should Be | locator, expected, message= | Verifies the value in text field identified by locator is exactly expected. message can be used to override default error message. Key attributes for text fields are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Title Should Be | title | Verifies that current page title equals title. | ||||||||||||||||||||||||||||||||||||||||||||||||
| Unselect Checkbox | locator | Removes selection of checkbox identified by locator. Does nothing if the checkbox is not checked. Key attributes for checkboxes are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Unselect Frame | Sets the top frame as the current frame. | |||||||||||||||||||||||||||||||||||||||||||||||||
| Unselect From List | locator, *values | Unselects given values from list identified by locator. As a special case, giving empty list as *selection will remove all selections. Key attributes for list are id and name. See introduction for details about locating elements. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Wait For Condition | condition, timeout=5 seconds, error=None | Waits either for given condition to be true or until timeout expires. condition can be arbitrary JavaScript expression. It can be multiple lines, but only the statement in the last line is used for evaluation. timeout must given using Robot Framework time syntax, see http://robotframework.googlecode.com/svn/trunk/doc/userguide/RobotFrameworkUserGuide.html#time-format. error can be used to override the default error message. New in version 2.2.3. See Execute JavaScript for information about accessing the actual contents of the window through JavaScript. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Wait Until Page Contains | text, timeout, error=None | Waits until text appears on current page or timeout expires. timeout must given using Robot Framework time syntax, see http://robotframework.googlecode.com/svn/trunk/doc/userguide/RobotFrameworkUserGuide.html#time-format. error can be used to override the default error message. New in version 2.2.3. Robot Framework built-in keyword Wait Until Keyword Succeeds can be used to get this kind of functionality for any Selenium keyword. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Wait Until Page Contains Element | locator, timeout, error=None | Waits until element specified with locator appears on current page or timeout expires. timeout must given using Robot Framework time syntax, see http://robotframework.googlecode.com/svn/trunk/doc/userguide/RobotFrameworkUserGuide.html#time-format. error can be used to override the default error message. This keyword was added in SeleniumLibrary 2.2.3. Robot Framework built-in keyword Wait Until Keyword Succeeds can be used to get this kind of functionality for any Selenium keyword. |