- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 to get the active sheet in a workbook in Selenium with python?
We can get the active sheet in a workbook in Selenium. Excel is a spreadsheet which is saved with the .xlsx extension. An excel workbook has multiple sheets and each sheet consists of rows and columns.
Out of all the worksheets, while we are accessing a particular sheet that is called as an active sheet. Each cell inside a sheet has a unique address which is a combination of row and column numbers.
The column number starts from alphabetic character A and row number starts from the number 1. A cell can contain numerous types of values and they are the main component of a worksheet.
To work with excel in Selenium with python, we need to take help of OpenPyXL library. This library is responsible for reading and writing operations on Excel, having the extensions like xlsx, xlsm, xltm, xltx.
To install OpenPyXL library, we have to execute the command pip install openpyxl. This is because OpenPyXL does not come by default with python. After this we should import openpyxl in our code and then we should be ready to interact with excel.
To get the active sheet in a workbook, first of all we need to load the entire workbook by specifying the path where it is located. This is achieved with load_workbook() method.
Syntax
wrkbk = load_workbook("C:\work\SeleniumPython.xlsx") # to identify the active sheet sh = wrkbk.active
Example
Coding Implementation to identify the active sheet.
import openpyxl # load excel with its path wrkbk = load_workbook("C:\work\SeleniumPython.xlsx") # to get the active work sheet sh = wrkbk.active
- Related Articles
- How to get the active workbook location/path in Excel?
- How to get all the values in a worksheet in Selenium with python?
- How to get the complete screenshot of a page in Selenium with python?
- How to get text with selenium web driver in python?
- How to close active/current tab without closing the browser in Selenium-Python?
- How to get the values of a particular row in a table in Selenium with python?
- How to get the current workbook name in Excel?
- How to get the screenshot of a particular element in the page in Selenium with python?
- How to get the value in a particular cell inside the worksheet in Selenium with python?
- How to get the inner text of a webpage with a Javascript executor in Selenium with python?
- How to get sheet names using openpyxl in Python?
- How do I switch to the active tab in Selenium?
- How to get the title and URL of a webpage with Javascript executor in Selenium with python?
- How to get the title and URL of the page in Selenium with python?
- How to get all the values including the headers inside a table in a page in Selenium with python?
