简体   繁体   中英

Name mapping between Chrome policies and Chrome experimental options in Selenium python

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.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM