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.

本文介绍了如何使用WebDriver配置Firefox浏览器以实现文件的自动下载,避免弹出下载对话框。通过设置Firefox配置文件偏好来指定下载目录及文件类型,并利用第三方工具如AutoIt处理特定情况下的下载操作。
1万+

被折叠的 条评论
为什么被折叠?



