How to set firefox profile preference by user.js file

116 views
Skip to first unread message

dinh nguyen

unread,
Apr 12, 2018, 5:26:08 AM4/12/18
to Selenium Users
Hi all, 
can any one show me the approach way to overriding  the existing firefox profile by using javascript file (user.js).
i see many framework they store the preferences in the file user.js. the content of the file is : 

user_pref("datareporting.policy.dataSubmissionPolicyAccepted", false);
user_pref("dom.max_chrome_script_run_time", 30);
user_pref("webdriver_enable_native_events", true);
user_pref("toolkit.networkmanager.disable", true);
user_pref("browser.offline", false);
user_pref("javascript.options.showInConsole", true);
user_pref("extensions.update.enabled", false);
user_pref("security.warn_entering_weak", false);
user_pref("browser.EULA.3.accepted", true);
user_pref("app.update.enabled", false);
user_pref("toolkit.telemetry.rejected", true);
user_pref("browser.search.update", false);
user_pref("browser.safebrowsing.malware.enabled", false);
user_pref("network.http.max-connections-per-server", 10);
user_pref("security.warn_leaving_secure.show_once", false);
user_pref("datareporting.healthreport.service.firstRun", false);

above is the content of user.js file. 
next how can i invoke the file in my selenium java code to overriding the existing firefox profile . many thanks

GK Kumar

unread,
Apr 14, 2018, 2:18:37 PM4/14/18
to Selenium Users
 can you try with below code ?
ProfilesIni profile = new ProfilesIni();     
FirefoxProfile myprofile = profile.getProfile("profile");     
WebDriver driver = new FirefoxDriver(myprofile);

Reply all
Reply to author
Forward
0 new messages