- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we read data from an excel sheet in Selenium Webdriver?
We can read data from an excel sheet in Selenium webdriver in Python.
An excel workbook consists of multiple sheets and each sheet consists of cells and columns.
To work with excel in Python(with extension .xlsx, .xlsm, and so on) we have to utilize the OpenPyXL library. To install this package, we have to run the command: pip install openpyxl. Also, we have to add the statement import openpyxl in our code.
To open an excel workbook, the method is load_workbook and pass the path of the excel file as a parameter to this method. To identify the active sheet, we have to use the active method on the workbook object.
To read a cell, the method cell is applied on the active sheet and the row and column numbers are passed as parameters to this method. Then the value method is applied on a particular cell to read values within it.
Let us read the value at the third row and second column having the value D as shown below in an excel workbook of name Data.xlsx −
import openpyxl #configure workbook path b = openpyxl.load_workbook("C:\Data.xlsx") #get active sheet sht = b.active #get cell address within active sheet cl = sht.cell (row = 3, column = 2) #read value with cell print("Reading value from row-3, col-2: ") print (cl.value)
- How to read test data from an excel sheet and use it to test facebook login in Selenium Webdriver?
- How many ways can we read data from the keyboard in Java?
- How can we handle authentication popup in Selenium WebDriver using Java?
- How can we read from standard input in Java?
- Excel Sheet Column Number in C++
- Excel Sheet Column Title in C++
- Write a Python program to read an Excel data from file and read all rows of first and last columns
- What can selenium WebDriver do?
- Python - Plotting charts in excel sheet with Data Tools using XlsxWriter module
- Adding a Chartsheet in an excel sheet using Python XlsxWriter module
- Exporting data from SAP system to an Excel Report
- How to retrieve value from an edit box using Selenium webdriver?
- How can I select date from a datepicker div using Selenium Webdriver?
- How can I get Webdriver Session ID in Selenium?
- Can we read from JOptionPane by requesting input from user in Java?