title: Grant access to video and audio in Chrome 48 via Selenium Chromedriver automatically
body: <p>I would like to automatically grant access to video and audio in Chrome via Chromedriver capabilities.</p>
  
  <p>Based on <a href="https://stackoverflow.com/a/16929608">this</a> (pretty old) answer I tried the following:</p>
  
  <pre><code>DesiredCapabilities capabilities = DesiredCapabilities.chrome();
  ChromeOptions options = new ChromeOptions();
  Map&lt;String, Object&gt; prefs = new HashMap&lt;&gt;();
  
  // with this chrome still asks for permission
  prefs.put("profile.managed_default_content_settings.media_stream", 1);
  prefs.put("profile.managed_default_content_settings.media_stream_camera", 1);
  prefs.put("profile.managed_default_content_settings.media_stream_mic", 1);
  
  // and this prevents chrome from starting
  prefs.put("profile.content_settings.exceptions.media_stream_mic.https://*,*.setting", 1);
  prefs.put("profile.content_settings.exceptions.media_stream_mic.https://*,*.last_used", 1);
  prefs.put("profile.content_settings.exceptions.media_stream_camera.https://*,*.setting", 1);
  prefs.put("profile.content_settings.exceptions.media_stream_camera.https://*,*.last_used", 1);
  
  // and this prevents chrome from starting as well
  prefs.put("profile.content_settings.pattern_pairs.https://*,*.media_stream.video", "Allow");
  prefs.put("profile.content_settings.pattern_pairs.https://*,*.media_stream.audio", "Allow");
  
  options.setExperimentalOption("prefs", prefs);
  capabilities.setCapability(ChromeOptions.CAPABILITY, options);
  </code></pre>
  
  <p>Any ideas on how to grant permissions correctly?</p>