自动下载在Firefox中不起作用 [英] Auto download is not working in firefox
本文介绍了自动下载在Firefox中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
自动下载在Firefox中不起作用.请帮我提供以下代码:
Auto download is not working in firefox. Please help me with below code:
FirefoxOptions options = new FirefoxOptions();
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.folderList",2); //Use for the default download directory the last folder specified for a download
profile.setPreference("browser.download.dir", "D:");
profile.setPreference("browser.download.useDownloadDir", true); profile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
profile.setPreference( "browser.download.manager.showWhenStarting", false );
profile.setPreference("pdfjs.disabled", true); // disable the built-in PDF viewer
options.setProfile(profile);
WebDriver driver = new FirefoxDriver(options);
推荐答案
对于excel,请尝试mime:
For excel try mime:
FirefoxOptions options = new FirefoxOptions();
options.addPreference("browser.download.folderList", 2)
.addPreference("browser.download.dir", downloadPath)
.addPreference("browser.helperApps.neverAsk.saveToDisk", "application/vnd.ms-excel,text/xml,application/x-excel,application/x-msexcel,application/xhtml+xml,application/octet-stream,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
WebDriver driver = new FirefoxDriver(options);
如何处理使用Selenium Webdriver下载excel时,请在firefox中下载弹出窗口
这篇关于自动下载在Firefox中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文