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
- OS: MacOS Big Sur / Ver. 11.2.3 (M1)
- Computer language: Python 3.6
- Target browser:Microsoft Edge / Ver.89.0.774.75
- Installed webdriver:I've already installed the appropriate one for the "Target browser".(URL:https://developer.microsoft.com/ja-jp/microsoft-edge/tools/webdriver/)
# 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"