use this code
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.manager.showWhenStarting", false);
profile.setPreference("browser.download.dir", "C:\\temp");
//profile.setPreference("browser.helperApps.neverAsk.openFile",
//"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,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet ");
profile.setPreference("browser.helperApps.neverAsk.saveToDisk",
"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,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet ");
profile.setPreference("browser.helperApps.alwaysAsk.force", false);
profile.setPreference("browser.download.manager.alertOnEXEOpen", false);
profile.setPreference("browser.download.manager.focusWhenStarting", false);
profile.setPreference("browser.download.manager.useWindow", false);
profile.setPreference("browser.download.manager.showAlertOnComplete", false);
profile.setPreference("browser.download.manager.closeWhenDone", true);
WebDriver driver = new FirefoxDriver(profile);
driver.get("http://qtpselenium.com/test/testdownload.php");
driver.findElement(By.xpath("html/body/a[1]")).click();
Can we do this in internet explorer. My project is focusing on IE.
I tried profiling in IE but no option to do.
Can you please suggest what I need to do in IE browser.
Thanks
I need to click on triangle icon in dialog window, and later on select Save as.
In order to click triangle icon how to get the ordinates of the dialog box?
use this blog's direction to handle IE 9 download box.
http://9to5it.com/internet-explorer-disable-do-you-want-to-open-or-save-this-file-prompt/
How to disable the “do you want to open or save this file?” prompt
The following solution is for InfoPath Template files. If you want to use another file type you will need to tweak this solution:
Launch Registry Editor (Start >> Run >> regedit.exe)
Expand HKEY_CURRENT_USER
Navigate to HKEY_CURRENT_USER \ Software \ Microsoft \ Windows \ Shell
If it doesn’t exist, create the AttachmentExecute key
Create the {0002DF01-0000-0000-C000-000000000046} key
Create a new Binary Value with the Name InfoPath.Solution.3
Re-launch IE and test – should be now working ok
if above does not work try this
http://stackoverflow.com/questions/19403855/how-to-download-a-file-in-ie10-using-selenium-webdriver