-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Description
Feature and motivation
I can set user preferences via the Profile object, but unless I am misreading the docs the API does not seem to provide a way to read the Firefox preferences from an initialized driver. These are stored in prefs.json together with a user.json, if it exists, and are available on the about:config page if you click on the 'Show All' button.
It seems strange to have the ability to set prefs, as below, without the ability to get their values - especially in a use-case where code may dynamically alter prefs and you need to know how one is set at any point in time.
profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.download.dir'] = "/tmp/webdriver-downloads"
options = Selenium::WebDriver::Firefox::Options.new(profile: profile)
driver = Selenium::WebDriver.for :firefox, options: options
profile['browser.download.dir'] # => undefined method `[]' for #<Selenium::WebDriver::Firefox::Profile:0x00007f5838737c50Usage example
For example, in Ruby you would get a preference just like setting it:
profile['browser.download.dir']And/or have a method which returns all the preferences, something like:
profile.prefs # => hash of all prefs and their valuesThese could either be read from the two json files on disk or by parsing the html table on the about:config page. The latter option would need to be done in a new (background) session as it would require navigating to that page.