"browser.download.manager.showwhenstarting" is not visible | Selenium Forum
M
Posted on 16/09/2016
In FF version 46.0, below properties are not visible
1) browser.download.manager.showwhenstarting
2) browser.download.manager.alertOnEXEOpen

Is there any alternate way to fix this and download files without getting popup window (with save and cancel buttons when download is clicked)

property highlighted in this screenshot is not visible

[attachment=1:1mr3yied]download show when starting.png[/attachment:1mr3yied]

[attachment=0:1mr3yied]download show when starting not visible.png[/attachment:1mr3yied]

M
Replied on 16/09/2016

do you want to download a file without prompt?


M
Replied on 16/09/2016

Iam able to download file in "Firefox" browser using "Robot" class.

But unable to download using firefox profile as "browser.download.manager.showwhenstarting" is not visible


M
Replied on 16/09/2016

please answer my question

do you want to download a file without prompt?


M
Replied on 18/09/2016

Yes. I want to download without prompt window


M
Replied on 18/09/2016

what is the mime type of your file?


M
Replied on 18/09/2016

PDF file

p.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/pdf");


M
Replied on 18/09/2016

use this it should work

[code:lm84onim]package com.soapuitutorial.propertie;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

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) throws IOException {

Path p1 = Paths
.get("path/to/.pdf/file");
String x = Files.probeContentType(p1);
System.out.println(x);


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.download.downloadDir", "c:\\temp");
profile.setPreference("browser.download.defaultFolder", "c:\\temp");

profile.setPreference(
"browser.helperApps.neverAsk.saveToDisk",
"application/octet-stream,application/vnd.ms-excel,application/csv,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://samplecsvs.s3.amazonaws.com/Sacramentorealestatetransactions.csv");
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[3]")).click();
driver.findElement(By.xpath("html/body/a[4]")).click();

}

}
[/code:lm84onim]