Skip to content

Writing front end tests with the RobotFramework and Selenium

Sterling Baldwin edited this page Jun 3, 2015 · 19 revisions

The RobotFramework is a generalized testing framework that can work with many languages, and by using the Selenium Library, allows us to exercise the front end as though a user were sitting there clicking their way through it. The setup is fairly easy, simply pip install robotframework, then go here and download the selenium library. Once you have downloaded and unzipped the library, cd to it and run python setup.py install.

Each test suite should exist in its own directory under tests/robot. Inside each suites directory, there should be a common_resources.txt file to specify any variables the suite will need, and the each test type will exist in its own file. Each test file can have an arbitrary amount of tests, but they should all be related to each other. For example a log in test would be something like:

test/
---login_tests/ ------common_resources.txt ------valid_login.txt ------invalid_login.txt

The resource file has three sections, the Settings, Variables, and Keywords. Settings holds the documentation string for the test suite, and imports the selenium library. The Variables section holds any variables that will be common throughout the suite, marked as ${VARIABLE_NAME} value

The Keyword section is the largest and most complex. Here you create any common functions that you may need to do several times throughout the suite. Generally anything that takes more then one or two of the default selenium keywords should be made into its own. An example keyword would be:

This Is An Example Keyword  [Arguments]  ${url}   ${element}
   Open Browser  ${ADDRESS}  ${BROWSER}
   Go To  ${url}
   Page Should Contain Element  ${element}

Clone this wiki locally