title: Is headless selenium Firefox on Mac OS X 10.12.16 possible?
body: <p>I am able to run Firefox webdriver using selenium in Python, but when I try the same code while adding in an option for "-headless", I get a traceback of <code>"SessionNotCreatedException: Message: Unable to find a matching set of capabilities"</code>.</p>
  
  <p>Is it possible to make it work and can someone share how they did it?</p>
  
  <p>Here is what I'm running:</p>
  
  <ul>
  <li>Python v. 3.5.0    </li>
  <li>Firefox v. 57.0.4    </li>
  <li>selenium v. 3.11.0      </li>
  <li>geckodriver v. 0.21.0 [recommended with Firefox 57+ and selenium
  3.11.0+]</li>
  </ul>
  
  <p>My file:</p>
  
  <pre><code>import os
  from selenium import webdriver
  from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
  from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
  from selenium.webdriver.chrome.options import Options
  
  # executable path == '/Users/helloorange/geckodriver'
  executable_path = os.path.expanduser("~/geckodriver")
  # firefox_profile == '/Users/helloorange/Library/Application Support/Firefox/Profiles/k9a5czjm.Default User'
  firefox_profile = "%s/%s" % (os.path.expanduser("~/Library/Application Support/Firefox/Profiles"), os.listdir(os.path.expanduser("~/Library/Application Support/Firefox/Profiles"))[0])
  firefox_binary = FirefoxBinary("/Applications/Firefox.app/Contents/MacOS/firefox") # Folder for Firefox v 57
  os.system("chmod a+x '%s'"%executable_path)
  
  options = Options()
  options.add_argument("--headless")
  options.binary = firefox_binary
  options.profile = firefox_profile
  
  wd = webdriver.Firefox(executable_path=executable_path, firefox_profile=firefox_profile, firefox_binary=firefox_binary, firefox_options=options, log_path="geckodriver.log")
  wd.get('http://google.com/')
  print(wd.current_url)
  wd.quit()
  </code></pre>
  
  <p>My traceback:</p>
  
  <pre><code>---------------------------------------------------------------------------
  SessionNotCreatedException                Traceback (most recent call last)
  &lt;ipython-input-2-8fdf4535f36e&gt; in &lt;module&gt;()
       23 options.profile = firefox_profile
       24 
  ---&gt; 25 wd = webdriver.Firefox(executable_path=executable_path, firefox_profile=firefox_profile, firefox_binary=firefox_binary, firefox_options=options, log_path="geckodriver.log")#,capabilities=capabilities)
       26 wd.get('http://google.com/')
       27 print(wd.current_url)
  
  ~/venv/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py in __init__(self, firefox_profile, firefox_binary, timeout, capabilities, proxy, executable_path, options, log_path, firefox_options, service_args)
      160                 command_executor=executor,
      161                 desired_capabilities=capabilities,
  --&gt; 162                 keep_alive=True)
      163 
      164         # Selenium remote
  
  ~/venv/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py in __init__(self, command_executor, desired_capabilities, browser_profile, proxy, keep_alive, file_detector, options)
      152             warnings.warn("Please use FirefoxOptions to set browser profile",
      153                           DeprecationWarning)
  --&gt; 154         self.start_session(desired_capabilities, browser_profile)
      155         self._switch_to = SwitchTo(self)
      156         self._mobile = Mobile(self)
  
  ~/venv/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py in start_session(self, capabilities, browser_profile)
      241         parameters = {"capabilities": w3c_caps,
      242                       "desiredCapabilities": capabilities}
  --&gt; 243         response = self.execute(Command.NEW_SESSION, parameters)
      244         if 'sessionId' not in response:
      245             response = response['value']
  
  ~/venv/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py in execute(self, driver_command, params)
      310         response = self.command_executor.execute(driver_command, params)
      311         if response:
  --&gt; 312             self.error_handler.check_response(response)
      313             response['value'] = self._unwrap_value(
      314                 response.get('value', None))
  
  ~/venv/lib/python3.5/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)
  --&gt; 242         raise exception_class(message, screen, stacktrace)
      243 
      244     def _value_or_default(self, obj, key, default):
  
  SessionNotCreatedException: Message: Unable to find a matching set of capabilities
  </code></pre>