使用firefox配置文件是:
protected FirefoxProfile firefoxProfile() {
fxProfile.setPreference("browser.download.folderList", 2);
fxProfile.setPreference("browser.download.dir", path);
fxProfile.setPreference("browser.download.manager.alertOnEXEOpen", false);
fxProfile.setPreference("browser.helperApps.neverAsk.openFile", "text/csv,application/csv,application/text");
fxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "text/csv,application/csv,application/text");
fxProfile.setPreference("browser.download.manager.showWhenStarting", false);
fxProfile.setPreference("browser.download.manager.focusWhenStarting", false);
fxProfile.setPreference("browser.download.useDownloadDir", true);
fxProfile.setPreference("browser.helperApps.alwaysAsk.force", false);
fxProfile.setPreference("browser.download.manager.alertOnEXEOpen", false);
fxProfile.setPreference("browser.download.manager.closeWhenDone", true);
fxProfie.setPreference("browser.download.manager.showAlertOnComplete", false);
fxProfile.setPreference("browser.download.manager.useWindow", false);
fxProfile.setPreference("services.sync.prefs.sync.browser.download.manager.showWhenStarting", false);
fxProfile.setPreference("pdfjs.disabled", true);
}
在此处使用个人资料初始化firefox驱动程序:
FirefoxBinary ffBinary = new FirefoxBinary();
ffBinary.setTimeout(TimeUnit.SECONDS.toMillis(180));
internalDriver = new FirefoxDriver(ffBinary, firefoxProfile());