How to handle download dialog box(AutoIT/Robot) | Selenium Forum
M
Posted on 02/11/2015
Hi team,

I have a requirement to download a xls/csv.., file from the dialog box and save in predefined location
1. Click on the arrow mark from dialog box
2. select "Save as" and save the file in prefered location

When I try with AutoIt i am unable to get the control of arrow mark
Also i tried with robot class by getting coordinates.

Please help me to resolve this issue. I have attached a sample screen shot

Thanks
Manoj

M
Replied on 02/11/2015

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();


M
Replied on 04/11/2015

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


M
Replied on 05/11/2015

for IE you have to use robot class.


M
Replied on 06/11/2015

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?

Responsive image

M
Replied on 06/11/2015

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