Download and save files in IE browser | Selenium Forum
M
Posted on 13/03/2016
can you please share me the code to download the and save files in IE browser, actually I am getting pop up window to open and save , cancel buttons in IE. I want to save the file with user input name for each and every time.

M
Replied on 14/03/2016

package com.soapuitutorial.propertie;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;

public class DownloadWithoutPrompt {
// http://stackoverflow.com/questions/34271396/how-to-handle-downloading-xlsx-file-in-firefox-using-webdriver-where-window-pop
public static void main(String[] args) {

FirefoxProfile profile = new FirefoxProfile();

profile.setPreference("browser.download.folderList", 2);

profile.setPreference("browser.download.manager.showWhenStarting",
false);

profile.setPreference("brower.download.dir", "C:\\temp"); // path of

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

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

}

}


M
Replied on 14/03/2016

Can i have the code for IE browser ??


M
Replied on 15/03/2016

for IE you have use robot class.

for more info

http://stackoverflow.com/questions/29792415/how-to-download-a-file-from-ie-browser-using-webdriver-selenium

http://sqa.stackexchange.com/questions/3169/downloading-a-file-in-internet-explorer-through-selenium