The Preferences
object provides a scripting interface to Mozilla Firefox settings. The object properties correspond to the settings specified in the Mozilla Firefox configuration file. To obtain the object use the Preferences
extended property of the Firefox process. This property is available if the Firefox Support plugin is installed and the Firefox browser is launched. To view this object in the Object Browser and explore the available settings, activate the Advanced view mode.
Tip: | Normally the Firefox preferences are set via the about:config page. To display the page start the Firefox browser, type about:config in the address bar, and press Enter. |
The object contains a number of categories that group properties according to their function. For example the preferences regarding accessibility are located under the accessibility
category.
The names of the object properties coincide with the entity names of corresponding preferences of the about:config
page. The properties can have Boolean, integer or string values. All properties have the read-write attribute and can be modified from a script. For example, the following code changes the startup page of the browser:
JavaScript, JScript
Sys.Browser("firefox").Preferences.browser.startup.homepage = "smartbear.com";
Python
Sys.Browser("firefox").Preferences.browser.startup.homepage = "smartbear.com"
VBScript
Sys.Browser("firefox").Preferences.browser.startup.homepage = "smartbear.com"
DelphiScript
Sys.Browser('firefox').Preferences.browser.startup.homepage := 'smartbear.com';
C++Script, C#Script
Sys["Browser"]("firefox")["Preferences"]["browser"]["startup"]["homepage"] = "smartbear.com";
Also, note that the approach described above does not work for the preferences whose names contain hyphens. For example, the code above will not work for the "network.automatic-ntlm-auth.trusted-uris" preference. To work with such preferences from your tests, use setBoolPref
, getBoolPref
, setCharPref
, getCharPrefm
and similar methods. The code below demonstrates the mentioned approach:
JavaScript, JScript
Sys.Browser("firefox").Preferences.setCharPref("network.automatic-ntlm-auth.trusted-uris", "smartbear.com");
Python
Sys.Browser("firefox").Preferences.setCharPref("network.automatic-ntlm-auth.trusted-uris", "smartbear.com")
VBScript
Call Sys.Browser("firefox").Preferences.setCharPref("network.automatic-ntlm-auth.trusted-uris", "smartbear.com")
DelphiScript
Sys.Browser('firefox').Preferences.setCharPref('network.automatic-ntlm-auth.trusted-uris', 'smartbear.com');
C++Script, C#Script
Sys["Browser"]("firefox")["Preferences"]["setCharPref"]("network.automatic-ntlm-auth.trusted-uris", "smartbear.com");
In JavaScript, JScript, C#Script and C++Script tests, you can also use the square bracket notation:
JavaScript, JScript
Sys.Browser("firefox").Preferences.network["automatic-ntlm-auth"]["trusted-uris"] = "smartbear.com";
C++Script, C#Script
Sys["Browser"]("firefox")["Preferences"]["network"]["automatic-ntlm-auth"]["trusted-uris"] = "smartbear.com";
For a description of each setting see the About:config entries and Category:Preferences pages of the MozillaZine Knowledge Base (http://kb.mozillazine.org).
See Also
Configure Browser Settings from Tests
Process Object
Preferences Property
AppInfo Object