看到很多人在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);