title: cannot parse capability: goog:chromeOptions from invalid argument: unrecognized chrome option: prefs
body: <p>I'm trying to use the Selenium WebDriver and ChromeDriver to connect to an existing session <strong>and</strong> set the download folder. For some reason, it always fails and throws the following errors:</p>
  <pre><code>&gt;&gt;&gt; from selenium import webdriver
  &gt;&gt;&gt;
  &gt;&gt;&gt; chromeOptions = webdriver.ChromeOptions()
  &gt;&gt;&gt;
  &gt;&gt;&gt; download_folder = &quot;D:\\Test&quot;
  &gt;&gt;&gt; preferences = {
  ... &quot;download.default_directory&quot; : download_folder
  ... }
  &gt;&gt;&gt; chromeOptions.add_experimental_option(&quot;prefs&quot;, preferences)
  &gt;&gt;&gt; chromeOptions.add_experimental_option(&quot;debuggerAddress&quot;, &quot;127.0.0.1:1111&quot;)
  &gt;&gt;&gt;
  &gt;&gt;&gt; chromeOptions.to_capabilities()
  {'browserName': 'chrome', 'version': '', 'platform': 'ANY', 'goog:chromeOptions': {'prefs': {'download.default_directory': 'D:\\Test'}, 'debuggerAddress': '127.0.0.1:1111', 'extensions': [], 'args': []}}
  &gt;&gt;&gt;
  &gt;&gt;&gt; driver_Chrome = &quot;D:\\chromedriver.exe&quot;
  &gt;&gt;&gt; driver_Web = webdriver.Chrome(executable_path=driver_Chrome, chrome_options=chromeOptions)
  Traceback (most recent call last):
    File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
    File &quot;C:\Users\username\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\chrome\webdriver.py&quot;, line 76, in __init__
      RemoteWebDriver.__init__(
    File &quot;C:\Users\username\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py&quot;, line 157, in __init__
      self.start_session(capabilities, browser_profile)
    File &quot;C:\Users\username\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py&quot;, line 252, in start_session
      response = self.execute(Command.NEW_SESSION, parameters)
    File &quot;C:\Users\username\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py&quot;, line 321, in execute
      self.error_handler.check_response(response)
    File &quot;C:\Users\username\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py&quot;, line 242, in check_response
      raise exception_class(message, screen, stacktrace)
  selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: cannot parse capability: goog:chromeOptions
  from invalid argument: unrecognized chrome option: prefs
  </code></pre>
  <p> </p>
  <p>However, if I remove either one of the <code>chromeOptions.add_experimental_option</code> lines then it works fine, which doesn't make sense to me:</p>
  <pre><code>&gt;&gt;&gt; from selenium import webdriver
  &gt;&gt;&gt;
  &gt;&gt;&gt; chromeOptions = webdriver.ChromeOptions()
  &gt;&gt;&gt;
  &gt;&gt;&gt; download_folder = &quot;D:\\Test&quot;
  &gt;&gt;&gt; preferences = {
  ... &quot;download.default_directory&quot; : download_folder
  ... }
  &gt;&gt;&gt; chromeOptions.add_experimental_option(&quot;prefs&quot;, preferences)
  &gt;&gt;&gt; # chromeOptions.add_experimental_option(&quot;debuggerAddress&quot;, &quot;127.0.0.1:1111&quot;)
  &gt;&gt;&gt;
  &gt;&gt;&gt; chromeOptions.to_capabilities()
  {'browserName': 'chrome', 'version': '', 'platform': 'ANY', 'goog:chromeOptions': {'prefs': {'download.default_directory': 'D:\\Test'}, 'extensions': [], 'args': []}}
  &gt;&gt;&gt;
  &gt;&gt;&gt; driver_Chrome = &quot;D:\\chromedriver.exe&quot;
  &gt;&gt;&gt; driver_Web = webdriver.Chrome(executable_path=driver_Chrome, chrome_options=chromeOptions)
  &lt;stdin&gt;:1: DeprecationWarning: use options instead of chrome_options
  
  DevTools listening on ws://127.0.0.1:4523/devtools/browser/e34332d4-50f0-4419-b9fb-37ede5f5602e
  &gt;&gt;&gt;
  </code></pre>
  <hr />
  <pre><code>&gt;&gt;&gt; from selenium import webdriver
  &gt;&gt;&gt;
  &gt;&gt;&gt; chromeOptions = webdriver.ChromeOptions()
  &gt;&gt;&gt;
  &gt;&gt;&gt; download_folder = &quot;D:\\Test&quot;
  &gt;&gt;&gt; preferences = {
  ... &quot;download.default_directory&quot; : download_folder
  ... }
  &gt;&gt;&gt; # chromeOptions.add_experimental_option(&quot;prefs&quot;, preferences)
  &gt;&gt;&gt; chromeOptions.add_experimental_option(&quot;debuggerAddress&quot;, &quot;127.0.0.1:1111&quot;)
  &gt;&gt;&gt;
  &gt;&gt;&gt; chromeOptions.to_capabilities()
  {'browserName': 'chrome', 'version': '', 'platform': 'ANY', 'goog:chromeOptions': {'debuggerAddress': '127.0.0.1:1111', 'extensions': [], 'args': []}}
  &gt;&gt;&gt;
  &gt;&gt;&gt; driver_Chrome = &quot;D:\\chromedriver.exe&quot;
  &gt;&gt;&gt; driver_Web = webdriver.Chrome(executable_path=driver_Chrome, options=chromeOptions)
  &gt;&gt;&gt;
  </code></pre>
  <p> </p>
  <p>I've expanded out the &quot;capabilities&quot; from each output and they seem fine to me:</p>
  <pre><code>{
      'browserName': 'chrome',
      'version': '',
      'platform': 'ANY',
      'goog:chromeOptions': {
          'prefs': {
              'download.default_directory': 'D:\\Test'
          },
          'debuggerAddress': '127.0.0.1:1111',
          'extensions': [],
          'args': []
      }
  }
  </code></pre>
  <hr />
  <pre><code>{
      'browserName': 'chrome',
      'version': '',
      'platform': 'ANY',
      'goog:chromeOptions': {
          'prefs': {
              'download.default_directory': 'D:\\Test'
          },
          'extensions': [],
          'args': []
      }
  }
  </code></pre>
  <p> </p>
  <p>My environment is as follows:</p>
  <ul>
  <li>Windows 10 version 2004</li>
  <li>Python 64-bit version 3.8.4 (latest)</li>
  <li>Selenium version 3.141.0 (latest)</li>
  <li>Google Chrome 64-bit version 84.0.4147.89 (latest), opened with argument <code>--remote-debugging-port=1111</code></li>
  <li>ChromeDriver version 84.0.4147.30</li>
  </ul>
  <p>Nothing I've found online has helped or been regarding this particular scenario.</p>
  <p> </p>
  <p><strong>Update 2020/09/07 23:26:</strong> Same problem with versions 85.0.4183.*.</p>