Robot Framework SeleniumLibrary Python BroswerDrivers

Test Automation Using Robot Framework

Muzi 2021/04/26 10:37:40

What is Robot Framework?

1. An open source test automation framework

2. The core framework is implemented using Python and runs also on Jython (JVM) and IronPython (.NET)

3. It uses the keyword-driven testing approach

4. Its testing capabilities can be extended by test library implemented either with Python or Java


Prerequisites, Installation, and Environment Setup

1. Install Python

2. Install Pip

3. Configure Path (Add Pyhton and PIP to PATH)

4. Use PIP to install robot framework  -- pip3 install robotframework

5. Use PIP to install SeleniumLibrary --- pip3 install robotframework-seleniumlibrary

6. Install Pycharm IDE and Intellibot plugin

7. Download Selenium Browserdrivers for the browsers


Simple Test Case

Basically, we want to test the search function of If the function is working well, the page should have at least one expression similar to ‘’47, 080 results for mobile”. The number of results will vary depending on the amount of results per page. See figure 2 for reference.



Figure 1



Figure 2


Writing a Test


A typical test file (*.robot) can have a maximum of four sections as shown in figure 3. Each section is written in this format: *** <section name> *** . For a robot framework script, the “Settings” section and the “Test case” sections are mandatory.



Figure 3


Also, the folder structure is important. For example, the results folder, as shown in figure 4, is where the test results will be stored.



Figure 4


The four sections are;

1. Settings

This is where libraries are declared. Since this framework is keyword-driven, therefore, we need to execute keywords. These keywords are defined in libraries. As shown in figure 2, in this article we use the selenium library.

2. Keywords

We specify keywords, which are words that define or execute certain actions. These keywords are put into libraries which are defined in “Settings” sections. For example, the keyword “Open Browser” and it opens a new browser instance to a url which is given as an argument. You can always check the full documentation of keys words in docs.

3. Variables

Here we declared variables that we will use throughout the whole test file.

4. Test Cases

This is the section where we  write the actual test using the keys words. To execute the test case shown in figure 1, we follow the below steps;

a. Open Browser  ${LOGIN_URL}  ${BROWSER} - open chrome browser with the ebay url.

b. Input Text  //*[@id="gh-ac"]  mobile  - the input text keyword types the given text into the text field identified by the locator. See the location elements sections in documentation for more details. In this example we use the xpath property of the input element in the ebay website.

c. Press Keys  //*[@id="gh-btn"]  [Return] - another keyword that simulates the user pressing key(s) to an element or on the active browser. In this line, we click the search button as shown in figure 5.

Figure 5

Page Should Contain  results for mobile  - check if the loaded page contains the text ‘results for mobile’.If this is true, then according to our test, the search functionality is working.

Close Browser - close browser

Test Results Analysis


To run the script, we use the robot command and run it on the terminal;

> robot -d <folder to store results> <test file>

Therefore, in our case it’s :


robot -d Results Tests/eBay/FunctionalTestSuite/BasicSearch.robot   

> robot -d Results Tests/eBay/FunctionalTestSuite/BasicSearch.robot   


Robot framework provides a detailed report of all the tests as shown in figure 6 and 7.


Figure 6


Figure 7


In cases where you have failed tests, the robot framework provides screenshots for the failed tests as shown in figure 8 to 10. For example, if we test for a different text after the search button has been clicked;


Page Should Contain  results for cars



This should make the test fail.



Figure 8

Figure 9

Figure 10.



The robot framework is a perfect tool for test automation.It supports keyword-driven, behaviour-driven and data-driven style of writing test cases. It is easy to learn, hence non technical people can use it.












A meticulous web developer with over a year of front end experience and passion for responsive web design.