Fix Python Selenium + Edge Message: session not created: No matching capabilities found Error – Python Tutorial

By | May 8, 2022

When we are using python selenium to control edge browser, we may get Message: session not created: No matching capabilities found error. In this tutorial, we will introduce you how to fix it.

Look at example code below:

from PIL import Image
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

driver = None
try:

    driver = webdriver.Chrome(executable_path=r"msedgedriver.exe")
    driver.set_page_load_timeout(30)
    driver.set_window_size(720, 800)
    driver.get(url)
    print(driver.page_source)
except Exception as e:
    print(e)
    if driver is not None:
        driver.quit()
        driver = None
finally:
    if driver is not None:
        driver.quit()
        driver = None

Here msedgedriver.exe is edge driver. We can download it from here.

https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

Then, we can use this driver to control edge like chrome.

Python Capture Website Screenshot Using Selenium: A Beginner Guide – Python Selenium Tutorial

However, run this example code, we will get:

Message: session not created: No matching capabilities found

Fix Python Selenium Edge Message session not created No matching capabilities found Error - Python Tutorial

How to fix this error?

From code we can find: we use webdriver.Chrome() to create a driver to control edege. It is wrong. We should use webdriver.Edge().

We should create a driver instance as follows:

driver = webdriver.Edge(executable_path=r"msedgedriver.exe")

Run this code again and we will find this error is fixed.