2017-05-15 6 views
0

を使ってFirefoxのプロフィール設定を設定できません最近、FireFox 53.0.3、Geckoドライバ0.16.1、Selenium 3.4.0にアップグレードしました。下記の私のコードは、このアップグレードの前にうまくいきました。アップグレード後、プロファイル設定を設定しようとするとエラーになります。誰かがこれに代わるものが何かを教えてもらえますか、これに対する代替案を見つけることができますか?私は既存の質問 - unable to set preferences for Firefox profile with Selenium (geckodriver 0.16)を読んだが、私はGeckodriveのこれらの代替品は何かに固執している。Selenium(3.4.0)とgeckodriver 0.16

profile.setPreference("webdriver.load.strategy", "unstable"); 
profile.setAssumeUntrustedCertificateIssuer(false); 
profile.setPreference("browser.download.dir", "C:\\Firefox"); 
profile.setPreference("browser.download.folderList", 2); 
profile.setPreference("browser.helperApps.neverAsk.openFile", 
     "text/csv,application/x-msexcel,application/excel,application/ms-excel,application/x-excel,application/vnd.ms-excel,image/png,image/jpeg,text/html,text/plain,application/msword,application/xml"); 
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", 
     "text/csv,application/x-msexcel,application/excel,application/ms-excel,application/x-excel,application/vnd.ms-excel,image/png,image/jpeg,text/html,text/plain,application/msword,application/xml"); 
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); 

答えて

1

この問題を理解するために多くの時間を費やしたので、この回答を投稿してください。私はFirefoxOptionsクラスを使ってみました。ブラウザが開いたら、about:configページで設定を確認し、設定が正しく行われました。

FirefoxOptions options = new FirefoxOptions(); 
FirefoxProfile profile = new FirefoxProfile(); 
profile.setPreference("webdriver.load.strategy", "unstable"); 
profile.setAssumeUntrustedCertificateIssuer(false); 
profile.setPreference("browser.download.dir", "C:\\download"); 
profile.setPreference("browser.download.folderList", 2); 
options.setProfile(profile); 
DesiredCapabilities capabilities = DesiredCapabilities.firefox(); 
capabilities.setCapability(FirefoxOptions.FIREFOX_OPTIONS, options); 
WebDriver driver = new FirefoxDriver(capabilities); 
driver.get("http://www.google.com"); 
System.out.println("Title====" + driver.getTitle()); 
関連する問題