You can inject Firefox profile at the time of creating the driver.
I am using Selenium 3. If you are using Selenium 2 you can directly pass the profile into driver. There's no need for FirefoxOptions.
lat-long-json: I used this code
FirefoxOptions opt = getFirefoxOptions();
WebDriver webDriver = new FirefoxDriver(opt);
//method for fire fox profile//////////////////////////////////
public static FirefoxProfile getFirefoxProfile() {
ProfilesIni profileIni = new ProfilesIni();
FirefoxProfile profile = profileIni.getProfile("webDriverProfile");
System.out.println("profile is null : " + (profile == null));
if (profile == null) {
profile = new FirefoxProfile();
}
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.dir", "download/path");
profile.setPreference(
"browser.helperApps.neverAsk.saveToDisk",
"application/pdf,application/octet-stream,"
+ "application/download,text/html,application/xhtml+xml");
profile.setPreference("pdfjs.disabled", true);
// profile.setPreference("dom.webnotifications.enabled", true);
profile.setPreference("geo.enabled", true);
profile.setPreference("geo.provider.use_corelocation", true);
profile.setPreference("geo.prompt.testing", true);
profile.setPreference("geo.prompt.testing.allow", true);
profile.setPreference("geo.wifi.uri", "path-to-loglatjson\\geo-location-ITPL.json");
// profile.setPreference("browser.helperApps.neverAsk.openFile",
// "application/pdf");
// profile.setPreference("browser.helperApps.alwaysAsk.force", false);
/*
* profile.setPreference("browser.download.manager.alertOnEXEOpen",
* false);
* profile.setPreference("browser.download.manager.focusWhenStarting",
* false); profile.setPreference("browser.download.manager.useWindow",
* false);
* profile.setPreference("browser.download.manager.showAlertOnComplete",
* false);
* profile.setPreference("browser.download.manager.closeWhenDone",
* false);
*/
return profile;
}