- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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
Using Extensions with Selenium & Python
We can use extensions with Selenium webdriver in Python. We can have multiple extensions of the Chrome browser while we manually open the browser and work on it.
However, while the Chrome browser is opened through Selenium webdriver, those extensions which are available to the local browser will not be present. To configure an extension, we have to obtain the .crx extension file of the extension.
Then we have to perform installation of the extension to the browser which is launched by Selenium. To get all the extensions available to the browser enter chrome://extensions on the browser address bar.
To get add an extension for example: Momentum, visit the link −
https://chrome.google.com/webstore/category/extensions and enter Momentum in the search box. Once the search results are displayed, click on the relevant option.
After clicking on the Momentum extension, the details of the extension gets displayed. Copy the URL of the extension as highlighted in the below image.
Now, navigate to the link: https://chrome−extension−downloader.com/ and paste the URL we have copied within the Download extension field.
The .crx file of the extension gets downloaded to our system. We should then save it in a desired location.
To add this extension to the Chrome browser, once it is launched by Selenium webdriver, we have to use the Options class. We shall create an object of this class and apply add_extension method on it.
The path of the .crx file of the extension that we want to add is passed as a parameter to that method. Finally, this information is passed to the webdriver object.
from selenium import webdriver from selenium.webdriver.chrome.options import Options #object of Options class op = Options() #set .crx file path of extension op.add_extension('C:\Users\Momentum_v0.92.2.crx') #set geckodriver.exe path driver = webdriver.Firefox(executable_path="C:\geckodriver.exe", options=op) driver.maximize_window() #launch browser driver.get("https://www.tutorialspoint.com/index.htm")
- Check if any alert exists using selenium with python.
- How to get selected option using Selenium WebDriver with Python?
- Handle Firefox Not Responding While Using Selenium WebDriver With Python?
- How to identify nth element using xpath in Selenium with python?
- Download image with Selenium Python
- Select iframe using Python and Selenium
- How to Select date from a datepicker with Selenium Webdriver using Python?
- How to use Selenium with Python?
- Google Search Automation with Python Selenium
- How install Selenium Webdriver with Python?
- Accessing HTML source code using Python Selenium.
- How to search a directory with file extensions in Java?
- Extensions of Freudian Theory
- Switch tabs using Selenium WebDriver with Java.