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.
I believe the available prefs are here: https://source.chromium.org/chromium/chromium/src/+/main:chrome/common/pref_names.cc
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.