WebDriver - set firefox auto download
作者: Max.Bai
时间: 2014/06
During testing when we need check the download file content, the browser will popup the download dialog.
How to skip the download dialog?
1. setting the profile
FirefoxProfile ffpf = new FirefoxProfile();
ffpf.SetPreference("browser.download.folderList", 2);
ffpf.SetPreference("browser.download.dir", "C:\\temp");
ffpf.SetPreference("browser.download.useDownloadDir", true);
ffpf.SetPreference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream, application/vnd.ms-excel, text/csv, application/zip, application/xls");
// Popup Windows
ffpf.SetPreference("browser.popups.showPopupBlocker", false);
//ffpf.SetPreference("dom.disable_open_during_load", false);
DesiredCapabilities caps = DesiredCapabilities.Firefox();
caps.SetCapability(FirefoxDriver.ProfileCapabilityName, ffpf.ToBase64String());
IWebDriver driver = new FirefoxDriver(caps);
2. Use 3rd tools
Like autoit and so on..
When the download dialog popup, execute autoit script to click and save, you can found the solution on internet.