1

I want to use Selenium on the "headless mode" to control the MS Edge browser.

However, I get an error and cannot move forward.

Please let me know the cause of this error and how to deal with it.

# Information about the environment

# Code

*The commented-out "Chrome" will launch normally.

from selenium import webdriver
from msedge.selenium_tools import Edge, EdgeOptions

path = '/Users/yuchikawa/Dropbox/My Mac (YuのMacBook Pro)/Documents/scraping/msedgedriver'
options = EdgeOptions()
options.use_chromium = True
options.add_argument('--headless')
desired_cap={}

driver = Edge(executable_path=path, options=options, capabilities=desired_cap)

# Error message

---------------------------------------------------------------------------
SessionNotCreatedException                Traceback (most recent call last)
<ipython-input-18-c9fe75e92b36> in <module>
     13 
     14 #driver = Edge(executable_path=path, options=options, capabilities=desired_cap)
---> 15 driver = Edge(executable_path=path, options=options, capabilities=desired_cap)
     16 

~/opt/anaconda3/envs/py36/lib/python3.6/site-packages/msedge/selenium_tools/webdriver.py in __init__(self, executable_path, capabilities, port, verbose, service_log_path, log_path, keep_alive, desired_capabilities, service_args, options)
    106                 remote_server_addr=self.service.service_url,
    107                 keep_alive=keep_alive),
--> 108                 desired_capabilities=desired_capabilities)
    109         except Exception:
    110             self.quit()

~/opt/anaconda3/envs/py36/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py in __init__(self, command_executor, desired_capabilities, browser_profile, proxy, keep_alive, file_detector, options)
    155             warnings.warn("Please use FirefoxOptions to set browser profile",
    156                           DeprecationWarning, stacklevel=2)
--> 157         self.start_session(capabilities, browser_profile)
    158         self._switch_to = SwitchTo(self)
    159         self._mobile = Mobile(self)

~/opt/anaconda3/envs/py36/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py in start_session(self, capabilities, browser_profile)
    250         parameters = {"capabilities": w3c_caps,
    251                       "desiredCapabilities": capabilities}
--> 252         response = self.execute(Command.NEW_SESSION, parameters)
    253         if 'sessionId' not in response:
    254             response = response['value']

~/opt/anaconda3/envs/py36/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py in execute(self, driver_command, params)
    319         response = self.command_executor.execute(driver_command, params)
    320         if response:
--> 321             self.error_handler.check_response(response)
    322             response['value'] = self._unwrap_value(
    323                 response.get('value', None))

~/opt/anaconda3/envs/py36/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py in check_response(self, response)
    240                 alert_text = value['alert'].get('text')
    241             raise exception_class(message, screen, stacktrace, alert_text)
--> 242         raise exception_class(message, screen, stacktrace)
    243 
    244     def _value_or_default(self, obj, key, default):

SessionNotCreatedException: Message: session not created: No matching capabilities found

#supplementary information The other day, you showed me how to use Selenium Edge on MacOS, but when I tried to use the headless mode, I got the error again. Edge browser driver does not launch in "Selenium"

  • Just for testing purposes, can you try to pass the capabilities like this? `desired_cap = { "os" : "OS X", "os_version" : "Catalina", "browser" : "Edge", "browser_version" : "83.0", "browserstack.local" : "false", "browserstack.selenium_version" : "3.5.2" }` Further for testing purposes, try to just pass the `options` parameter and see whether it works or not. – Deepak-MSFT Apr 16 '21 at 11:24
  • Thank you for the answer!! I tried your answer. First, I execute the word you said. But, the same error occured. Second, as follows I executed. But, the same error occured. desired_cap = { "os" : "OS X" , "os_version" : "Big Sur" , "browser" : "Edge" , "browser_version" : "90.0" , "browserstack.local" : "false" , "browserstack.selenium_version" : "3.141.0" } Also I execute it except for "options". But, the same error occured. – YU UCHIKAWA Apr 19 '21 at 01:16

0 Answers0