1

I would like to set some Chrome policies listed here using Selenium. My problem here is that I don't know how to map the Chromium policy names to the preference names to pass to the Chrome driver in Selenium.

Based on this question, the policy SafeBrowsingEnabled becomes:

from selenium.webdriver.chrome.options import Options as ChromeOptions

chrome_options = ChromeOptions()
chrome_options.add_experimental_option(
    'prefs', {
        'safebrowsing.enabled': 'false'
    }
)

Based on this question, the policy DownloadRestrictions becomes:

from selenium.webdriver.chrome.options import Options as ChromeOptions

chrome_options = ChromeOptions()
chrome_options.add_experimental_option(
    'prefs', {
        'download_restrictions': 3
    }
)

Based on this question, the policy DefaultDownloadDirectory becomes:

from selenium.webdriver.chrome.options import Options as ChromeOptions

chrome_options = ChromeOptions()
chrome_options.add_experimental_option(
    'prefs', {
        'download.default_directory': '/path/to/folder',
    }
)

But where are these mappings coming from? I was unable to find any documentation about this.

revy
  • 3,945
  • 7
  • 40
  • 85
  • Optionally, you could use `addArguments()`, and [this SO answer](https://stackoverflow.com/a/42530229/1431750) lists the sources. Yes, it's unfortunate that it's not easily found in documentation. – aneroid Jul 18 '20 at 12:20
  • Thanks but that refers to the command line switches. I am talking about Chrome policies/preferences – revy Jul 18 '20 at 14:08

1 Answers1

0

I believe the available prefs are here: https://source.chromium.org/chromium/chromium/src/+/main:chrome/common/pref_names.cc

robd
  • 9,646
  • 5
  • 40
  • 59