Sunday, December 7, 2014

How to download files in Mozilla using Selenium Webdriver

FirefoxProfile firefoxProfile = new FirefoxProfile();

firefoxProfile.setPreference("browser.download.folderList",2);
firefoxProfile.setPreference("browser.download.manager.showWhenStarting",false);
firefoxProfile.setPreference("browser.download.dir","c:\\downloads");
firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk","text/csv");

Here text/csv is a mime type, change this mime type depending on the file type you want to download

Popular mine types

PDF => application/pdf
Text file => text/plain
.exe => application/octet-stream
MS Doc => application/msword
xls => application/excel
.zip => application/x-compressed
.tgz => application/gnutar

No comments:

Post a Comment