How to handle file download popup in selenium webdriver

Sunday, May 4, 2014

I have written a code to download an excel file, it is working, but it stops as soon as the popup appears. Automatically it should download the file and store in specified location, which is not happening now. Please anyone help in finding a solution for this problem



FirefoxProfile profile = new FirefoxProfile();
WebDriver driver = new FirefoxDriver(profile);


profile.setPreference("browser.helperapps.neverAsk.saveToDisk" , "text/csv");
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.dir","e:\\SampleExcel");

driver.get("http://url");
driver.findElement(By.name("email")).sendKeys("abc@gmail.com");
driver.findElement(By.name("pass")).sendKeys("abc");
driver.findElement(By.id("edit-submit")).click();
driver.findElement(By.id("toolbar-link-admin-config")).click();
driver.findElement(By.linkText("Reports")).click();
driver.findElement(By.xpath("//input[@value='5']")).click();
driver.findElement(By.id("edit-submit")).click();






http://ift.tt/1iTG8nX