Read Excel using Python in Robot Framework | Devstringx Technologies

In this blog you will learn how to create a python function to read and fetch the data from excel sheet and then call that function in your robot class.

Read Employee Name from the excel file whose screenshot is shared as below:

Create a function to read data from Excel File using Python

First Install Openpyxl library in your system as per the steps mentioned below:
1. Open command prompt.

2. Write “pip install robotframework-openpyxllib” command to install openpyxl library.

Now create a python file. You can give any name to your file and save it with .py extension.

I have created a file python file as

Here I have created a function as open_and_read_excel_file and passed three parameters in that function. Use all the parameters are stated below:
a) sheetname — You can pass the sheet name to read the data from particular sheet by specifying the sheet name.
b) column_value — Give column value whose data you want to get.
c) file — Give name of excel file which you have created.

Use ‘Data only’ property if you want to fetch the value of cell instead of formula.

All above mentioned parameters we will pass at a time of function call through robot framework.

Calling python function in robot framework to read excel data.

Let’s save this file with “TestExcel.robot”

Run the above file by using the following command:
> robot TestExcel.robot



Originally published at on Aug 17, 2021

Devstringx Technologies is highly recommended IT company for custom software development, mobile app development and automation testing services