Skip to content

Instantly share code, notes, and snippets.

@fliedonion
Last active November 29, 2023 08:38
Show Gist options
  • Save fliedonion/86bb8f60def00d1f531e92c1ff148234 to your computer and use it in GitHub Desktop.
Save fliedonion/86bb8f60def00d1f531e92c1ff148234 to your computer and use it in GitHub Desktop.
selenium with Microsoft Edge on Mac OS X.
# coding: utf-8
from selenium import webdriver
edge_options = {
"executable_path": "/Users/takahiro/selenium-webdrivers/edge-83/msedgedriver",
# ofcourse change path to driver you downloaded.
"capabilities": {
"platformName": 'mac os x', # I get this from Chrome driver's capabilities
# "os" : "OS X", # also ok.
}
}
browser = webdriver.Edge(**edge_options)
browser.get('http://localhost:8000')
assert 'Title Text' in borwser.title

The code:

from selenium import webdriver

browser = webdriver.Edge('/Path/To/Correct/msedgedriver')

raises following exception:

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

this gist shows concrete code how do I fix it.

see also: https://stackoverflow.com/a/62260786

browser = webdriver.Edge(**edge_options) is same as:

browser = webdriver.Edge(executable_path="/Users/takahiro/selenium-webdrivers/edge-83/msedgedriver", capabilities={ "platformName": 'mac os x', })

sample To get capability from created driver

from selenium import webdriver
from pprint import pprint

browser = webdriver.Chrome('/Path/To/Correct/chromedriver")
pprint(browser.capabilities)

sample output:

{'acceptInsecureCerts': False,
 'browserName': 'chrome',
 'browserVersion': '83.0.4103.106',
 'chrome': {'chromedriverVersion': '83.0.4103.39 '
                                   '(ccbf011cb2d2b19b506d844400483861342c20cd-refs/branch-heads/4103@{#416})',
            'userDataDir': '/var/folders/qc/qrbfyzcx6jx8b7fh8cqstwgh0000gn/T/.com.google.Chrome.ukFJzK'},
 'goog:chromeOptions': {'debuggerAddress': 'localhost:50551'},
 'networkConnectionEnabled': False,
 'pageLoadStrategy': 'normal',
 'platformName': 'mac os x',
 'proxy': {},
 'setWindowRect': True,
 'strictFileInteractability': False,
 'timeouts': {'implicit': 0, 'pageLoad': 300000, 'script': 30000},
 'unhandledPromptBehavior': 'dismiss and notify',
 'webauthn:virtualAuthenticators': True}

edge driver capability sample output:

{'acceptInsecureCerts': False,
 'browserName': 'msedge',
 'browserVersion': '83.0.478.54',
 'ms:edgeOptions': {'debuggerAddress': 'localhost:50429'},
 'msedge': {'msedgedriverVersion': '83.0.478.54 '
                                   '(59fa2a2680c37e7ed7af1c9b07be6ec4aa9cda2a)',
            'userDataDir': '/var/folders/qc/qrbfyzcx6jx8b7fh8cqstwgh0000gn/T/.org.chromium.Chromium.UUOi5f'},
 'networkConnectionEnabled': False,
 'pageLoadStrategy': 'normal',
 'platformName': 'mac os x',
 'proxy': {},
 'setWindowRect': True,
 'strictFileInteractability': False,
 'timeouts': {'implicit': 0, 'pageLoad': 300000, 'script': 30000},
 'unhandledPromptBehavior': 'dismiss and notify',
 'webauthn:virtualAuthenticators': True}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment