MSEdgeDriver – session not created: No matching capabilities found error on Selenium with Python

Question:

Having some trouble getting our automation to run on Microsoft Edge. Have the correct browser version driver installed and have tried a few other ‘fixes’ to no avail. This is using Selenium with Python3 on PyCharm.

Going back to the beginning, this is my code…

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.edge.options import Options
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys

options = Options()
driver = webdriver.Edge(executable_path='/Users/james.stott/PycharmProjects/venv/Selenium/Remote/msedgedriver')

And the following is the error raised…

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

Any help at all, would be greatly appreciated.

Asked By: James Stott

||

Answers:

I guess you’re using Edge Chromium, you can refer to the steps below to automate Edge browser using Selenium python code:

  1. Download and install the Python from this link.

  2. Launch the command prompt as an Administrator.

  3. Run the command below to install the Edge Selenium tools.

    pip install msedge-selenium-tools selenium==3.141
    
  4. Install the correct version of the Edge web driver from this link. (The WebDriver version should be the same as the Edge browser version)

  5. Create a Python file using the code below and modify it as per your own requirements.

    from msedge.selenium_tools import Edge, EdgeOptions
    
    options = EdgeOptions()
    options.use_chromium = True
    options.binary_location = r"C:Program Files (x86)MicrosoftEdgeApplicationmsedge.exe"
    driver = Edge(executable_path = r"D:selenium web driversedge drivermsedgedriver.exe", options = options) # Modify the path here...
    driver.get("https://example.com")
    

Update:

You need to send capabilities if you’re using Mac OS. You can try to send an empty capability:

desired_cap={}

driver = webdriver.Edge(executable_path='/Users/james.stott/PycharmProjects/venv/Selenium/Remote/msedgedriver', capabilities=desired_cap)
Answered By: Yu Zhou

For linux users using executable_path as EdgeChromiumDriverManager or any given path, follow the following snippet:

from selenium import webdriver
from webdriver_manager.microsoft import EdgeChromiumDriverManager

driver = webdriver.Edge(executable_path=EdgeChromiumDriverManager().install(), capabilities={"platform": "LINUX"})
Answered By: Mahery Ranaivoson