问题
I couldn't really find this information anywhere, I am looking for a list of possible keys that can be used in the profile.set_preference()
API.
Here is some context:
from selenium import webdriver
from pyvirtualdisplay import Display
display = Display(visible=0, size=(1024, 768))
display.start()
profile = webdriver.FirefoxProfile()
Now, if I want to, say specify a client SSL, I need to configure that as a preference of FireFox profile. I am trying to find the list of all the preferences so I can play with this.
回答1:
You can look at profile.DEFAULT_PREFERENCES
which is the json
at python2.7/site-packages/selenium/webdriver/firefox/webdriver_prefs.json
{u'frozen': {u'app.update.auto': False,
u'app.update.enabled': False,
u'browser.EULA.3.accepted': True,
u'browser.EULA.override': True,
u'browser.displayedE10SNotice': 4,
u'browser.download.manager.showWhenStarting': False,
u'browser.link.open_external': 2,
u'browser.link.open_newwindow': 2,
u'browser.offline': False,
u'browser.reader.detectedFirstArticle': True,
u'browser.safebrowsing.enabled': False,
u'browser.safebrowsing.malware.enabled': False,
u'browser.search.update': False,
u'browser.selfsupport.url': u'',
u'browser.sessionstore.resume_from_crash': False,
u'browser.shell.checkDefaultBrowser': False,
u'browser.tabs.warnOnClose': False,
u'browser.tabs.warnOnOpen': False,
u'datareporting.healthreport.logging.consoleEnabled': False,
u'datareporting.healthreport.service.enabled': False,
u'datareporting.healthreport.service.firstRun': False,
u'datareporting.healthreport.uploadEnabled': False,
u'datareporting.policy.dataSubmissionEnabled': False,
u'datareporting.policy.dataSubmissionPolicyAccepted': False,
u'devtools.errorconsole.enabled': True,
u'dom.disable_open_during_load': False,
u'extensions.autoDisableScopes': 10,
u'extensions.blocklist.enabled': False,
u'extensions.logging.enabled': True,
u'extensions.update.enabled': False,
u'extensions.update.notifyUser': False,
u'javascript.enabled': True,
u'network.http.phishy-userpass-length': 255,
u'network.manage-offline-status': False,
u'offline-apps.allow_by_default': True,
u'prompts.tab_modal.enabled': False,
u'security.csp.enable': False,
u'security.fileuri.origin_policy': 3,
u'security.fileuri.strict_origin_policy': False,
u'security.warn_entering_secure': False,
u'security.warn_entering_secure.show_once': False,
u'security.warn_entering_weak': False,
u'security.warn_entering_weak.show_once': False,
u'security.warn_leaving_secure': False,
u'security.warn_leaving_secure.show_once': False,
u'security.warn_submit_insecure': False,
u'security.warn_viewing_mixed': False,
u'security.warn_viewing_mixed.show_once': False,
u'signon.rememberSignons': False,
u'toolkit.networkmanager.disable': True,
u'toolkit.telemetry.enabled': False,
u'toolkit.telemetry.prompted': 2,
u'toolkit.telemetry.rejected': True},
u'mutable': {u'browser.dom.window.dump.enabled': True,
u'browser.newtab.url': u'about:blank',
u'browser.newtabpage.enabled': False,
u'browser.startup.homepage': u'about:blank',
u'browser.startup.page': 0,
u'dom.max_chrome_script_run_time': 30,
u'dom.max_script_run_time': 30,
u'dom.report_all_js_exceptions': True,
u'javascript.options.showInConsole': True,
u'network.http.max-connections-per-server': 10,
u'startup.homepage_welcome_url': u'about:blank',
u'webdriver_accept_untrusted_certs': True,
u'webdriver_assume_untrusted_issuer': True}}
回答2:
I usually just open about:config
and search the list of preferences there. There is also this helpful resource which documents part of the preferences.
来源:https://stackoverflow.com/questions/38316910/python-selenium-what-are-possible-keys-in-firefox-webdriver-profile-preference