0

Tried the following ways. First approach :

from selenium import webdriver
from msedge.selenium_tools import EdgeOptions
from msedge.selenium_tools import Edge
options = EdgeOptions()
options.use_chromium = True
driver = Edge(options = options)
driver.get('https://www.google.com/')

Output: FileNotFoundError: [Errno 2] No such file or directory: 'msedgedriver'

Second Approach: Gave the path of the edge driver but then also it's not launching

desired_cap = {}
sys.path.append('/Users/lr02023/Downloads/edgedriver_mac64/msedgedriver')
options = EdgeOptions()
options.use_chromium = True
driver = Edge(options 
= options,executable_path='/Users/XXXXX/Downloads/edgedriver_mac64/
msedgedriver',capabilities=desired_cap)

Output : selenium.common.exceptions.SessionNotCreatedException: Message: session not created: No matching capabilities found

In Second Approach Tried using options.binary_location but still same error no matching capabilities found

Third Approach which is working:

from selenium import webdriver
driver = 
webdriver.Edge(executable_path='/Users/XXXXX/Downloads/edgedriver_mac64/
msedgedriver',capabilities=desired_cap)
driver.get('https://www.google.com/')

Output : Opens google.com

Third Approach launches edge using Selenium+Python.But i want to add Extension to the edge browser and test on it so that's not working. Tried options.add_extension("path of CRX file") -> Edge Options is Not working

Is there anyway to add extension to edge browser using Selenium+Python?Can someone help me.

Lavanya
  • 1
  • 1
  • 2

1 Answers1

0

You had asked,"Is there any way to add an extension to edge browser using Selenium + Python?"

Below is the Selenium Python sample code that can help you add an extension to the Edge browser.

from msedge.selenium_tools import Edge, EdgeOptions
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

options = EdgeOptions()
options.use_chromium = True
#options.add_argument("-inprivate")
options.binary_location = r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
options.add_extension(r"Path_to_your_extension_here...\extension_name.crx") # Modify the path here...
capabilities = DesiredCapabilities.EDGE

driver = Edge(executable_path = r"Path_to_the_Edge_web_driver_here..\msedgedriver.exe", options = options,desired_capabilities=capabilities) # Modify the path here...

driver.get("http://Your_website_address_here...") # Modify the URL here...

# Perform some automation here...

driver.quit

Test result with the MS Edge 89.0.774.75 version:

enter image description here

Further, you can modify the code sample as per your own requirements.

Deepak-MSFT
  • 10,379
  • 1
  • 12
  • 19
  • Hi I tried this approach but still i'm getting selenium.common.exceptions.SessionNotCreatedException: Message: session not created: No matching capabilities found. I'm using Selenium version 3.14 in Mac OS and i think it doesn't have the capability to add an extension in Edge.Can you please tell in which version of selenium you are able to add the extension. – Lavanya Apr 14 '21 at 15:34
  • @Lavanya, I try to check the Selenium version on my end and it looks like I am using the **Selenium 3.141.0** version. you can see my test result [here](https://imgur.com/a/FJLXyOS). – Deepak-MSFT Apr 15 '21 at 06:21