Webdriver设置Firefox自动下载

看到很多人在firefox上操作下载窗口用autoit,太麻烦了,提供一种用profile来解决的办法:

FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("browser.download.dir", "c:\data"); profile.setPreference("browser.download.folderList", 2); //browser.download.folderList 设置Firefox的默认 下载 文件夹。0是桌面;1是“我的下载”;2是自定义 profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream, application/vnd.ms-excel, text/csv, application/zip"); driver = new FirefoxDriver(profile);
原文地址:https://www.cnblogs.com/zhangfei/p/3779518.html