Test Automation Using Robot Framework

Muhammad Ahsan Mehdi
3 min readNov 25, 2023

--

Automating software tests is immensely beneficial, particularly when dealing with multiple software releases. As a tester, having knowledge of efficient test automation frameworks and tools is crucial. Among the various frameworks available, the Robot Framework stands out for its inherent support for Behavior Driven Development (BDD) without the need for installing Cucumber.

In this article, I will guide you through the step-by-step process of implementing your first test case in the Robot Framework.

Pre-requisites

  1. Python

Make sure you have python & installed on your system. You can download and install them from the official website.

2. Visual Studio Code

Make sure you have visual studio code installed on your system. You can download and install them from the official website.

3. Google Chrome Browser

Make sure you have google installed on your system. You can download and install them from the official website.

Installation & Configuration

1. Create Folder

First, we need to create a folder at any location in your device.

2. Chrome Driver Setup

First, please find out the version of chrome browser installed on your system, then download the related driver from website.

After that copy the downloaded chromedriver.exe file and paste in the folder created in first step.

3. Install Robot Framework

Run the following command in command prompt to install Robot Framework.

pip install robotframework

4. Install Robot Framework Selenium Library

Run the following command in command prompt to install Robot Framework Selenium Library.

pip install robotframework-seleniumlibrary

you can check your installation using robot — version in cmd. Now open the vs code and install the robot and python extensions as shown below:

Implementation

  1. Create Robot file

Now you must open the folder having chrome driver in vs code and create a robot file with dot robot extension. You folder directory should be look like as shown in image below:

2. Copy the code below and paste inside the sample. Robot file:

The given script uses the Robot Framework with the SeleniumLibrary to automate testing on a web page. It follows a Behavior-Driven Development (BDD) style with a test case focused on the terms and conditions page. The script opens a specified URL, verifies the URL, clicks on a terms and conditions link, and checks for the presence of specific text on the resulting page. Keywords are defined to encapsulate these actions, promoting modular and reusable test automation.

3. Run code

now open the terminal in vs code and run the following command:

robot sample.robot

Note: robot keyword, file name and dot robot

Results

For results open the report.html or log.html as shown in image below:

Keypoint: In Robot Framework, there are instances where using tab space is necessary instead of a single space. I will provide detailed explanations in upcoming articles.

Conclusion:

So, we can utilize Robot for behavior-driven development in Visual Studio Code. This approach simplifies our work, involving just single file. For adding more test cases just add your other test cases and then implement the required keywords.

In last, I would like to say!
Thank you for your valuable time. Please send me notes on this article if you have any questions regarding the topic.

For better communication, let’s connect via LinkedIn.

--

--