use this link http://stackoverflow.com/questions/34271396/how-to-handle-downloading-xlsx-file-in-firefox-using-webdriver-where-window-pop
and use this code
[code:11w0luti]public static void main(String[] args) {
FirefoxProfile profile = new FirefoxProfile();
// //0 desktop, 1 download folder 2 specified folder
profile.setPreference("browser.download.folderList", 2);
// prevent download Managerwindow are coming
profile.setPreference("browser.download.manager.showWhenStarting",
false);
//
profile.setPreference("brower.download.dir", "C:\\temp"); // path of
// folder
// where you
// wnat to
// download.
// what kind of file should be download automatically on drive, this
// property explain that
// mine type- any file exe, xls, word, txt etc have there own mine type.
// google- type mine types of files specified here
profile.setPreference(
"browser.helperApps.neverAsk.saveToDisk",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,text/csv,application/x-msexcel,application/excel,application/x-excel,application/vnd.ms-excel,image/png,image/jpeg,text/html,text/plain,application/msword,application/xml");
profile.setPreference("browser.download.manager.showWhenStarting",
false);
profile.setPreference("browser.download.manager.alertOnEXEOpen", false);
// now we want to download file
// so here open firefox with specified profile
WebDriver driver = new FirefoxDriver(profile);
driver.get("http://qtpselenium.com/test/testdownload.php");
driver.findElement(By.xpath("html/body/a[1]")).click();
driver.findElement(By.xpath("html/body/a[2]")).click();
driver.findElement(By.xpath("html/body/a[4]")).click();
}
[/code:11w0luti]
I have writtten the same code. no difference...
eventhrought i used your code, still it is not working. I feel that basic problem here is, open file radio button is by default selected. What do you thing.
If so then how should I handle it.
with the code i have given you is working it will download your xlsx and docx files with prompting.