Robot Framework

Robot Framework Automation using Selenium and Python

Robot Framework

Robot Framework is a generic open-source automation framework. It was initially developed by Pekka Klarck at Nokia Networks. It is software released under Apache License 2.0. Most of its libraries and tools in the ecosystem are open source.  

This framework is mostly used for acceptance testing, acceptance test-driven development (ATDD), behavior-driven development (BDD), and robotic process automation (RPA). It uses a keyword-testing technique approach. Also, the capabilities can be extended by test libraries that either java or python can implement. 

Prerequisites: 

  1. Install Python 
  2. Install PIP 
  3. Install PyCharm IDE  
  4. Download Selenium Browser drivers for the browsers 

Installation: 

If you already have Python with PIP installed, Open the terminal and navigate to the python folder. Now type the following command to install the required packages: 

  • Install selenium 
Install selenium
  • Install robotframework
Install Robot Framework

or install robotframework==2.9.2 (for specific version) 

Install Robot Framework
  • Install robotframework-seleniumlibrary 
Install Robot Framework- selenium library

To Install IntelliBot #patched for PyCharm to identify robot-related files or robot framework test cases, do the following steps: 

  • Go to settings in PyCharm 
  • Select Plugins  
  • Search for IntelliBot #patched 
  • Click on the install option for IntelliBot #patched 
IntellBot Plugin
  • Restart pycharm IDE

Project Folder Structure : 

Basically, the folder structure contains multiple directories. Usually, in a robot framework, the key directories that we need to add to any project are the tests directory, resources directory, library directory, and results directory.  

Project Folder Structure
  1. Tests – In this directory, all the test cases are organized. 
  2. Resources – This directory contains the commonly used keywords. 
  3. Results – In this directory all the result files i.e. execution logs are stored. 
  4. Libraries – This directory contains custom libraries.

Files that we use in our robot framework project and their extensions: 

.robot: files that contain robot framework test case 

.xls: excel file that holds the test data 

.txt: notepad that maintains the data 

.py: python files to implement the code for the keyword 

First Test in Robot Framework: 

  • Step1: Create a file under the ‘Tests’ folder with the .robot extension. The .robot files are considered as Test Suites by Robot Framework. 
Step 1
  • Step2: Mention the four sections in the robot file as follows: 

***Settings*** – This section imports test libraries, resource files, and variable files. 

***Variables*** – This section contains the defined variables that are used              commonly 

***Test Cases*** –  In this section, we write our test cases 

***Keywords*** – In this section we can define our own keywords 

Step 2
  • Step3: Write a test case to launch the browser 
Step 3
  1. Launch Browser: It is the name of the test case 
  2. Library Selenium Library: This imports the selenium library into our test so that we can use the selenium commands. 
  3. Open browser: Keyword in robot framework which opens the URL in the browser. 
  • Step4: Execute the Testcase using the below command
Step 4

Stay tuned for more Robot Framework blogs.