Downloading an executable with Selenium and Firefox Automatically

0 votes

I'm using Selenium Web Driver and C# to automate automatically downloading an executable when I click on a link in Firefox.

FirefoxProfile profile = new FirefoxProfile();

profile.AcceptUntrustedCertificates = true;

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

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

profile.SetPreference("browser.download.dir", "c:\\Test");

profile.SetPreference("browser.helperApps.alwaysAsk.force", false);

profile.SetPreference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream");

IWebDriver driver = new FirefoxDriver(profile);

When I click the link, it still shows the Save dialog, but it does save it to my Test folder if I click Save. I'm using Firefox 21. How do I ensure the Save dialog doesn't appear and the download happens automatically?

Jun 29, 2018 in Selenium by Martin
• 4,220 points
59 views

1 answer to this question.

0 votes

Below will help:

When you create your driver:

FirefoxProfile profile = new FirefoxProfile();

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

profile.setPreference("browser.download.manager.closeWhenDone", true);

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

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

profile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/x-msdownload");

FirefoxDriver driver = new FirefoxDriver(profile)
answered Jun 29, 2018 by Samarpit
• 5,130 points

Related Questions In Selenium

0 votes
1 answer

Selenium IDE (2.9.1.1-signed) not working with latest Version of Firefox

Unfortunately, Selenium IDE will be deprecated soon. ...READ MORE

answered Mar 30, 2018 in Selenium by nsv999
• 5,050 points

edited Apr 4, 2018 by nsv999 2,567 views
0 votes
1 answer
0 votes
1 answer

How do i change the location where my file gets downloaded in Selenium Webdriver and firefox driver?

There are a couple of errors there. ...READ MORE

answered Apr 12, 2018 in Selenium by nsv999
• 5,050 points
1,240 views
0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
273 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
639 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
264 views
0 votes
1 answer

Firefox browser not opening with given URL using Selenium Webdriver with Java

Download the latest selenium jar and replace ...READ MORE

answered Apr 30, 2018 in Selenium by Samarpit
• 5,130 points
1,917 views
0 votes
1 answer

NoSuchElementException exception with headless chrome and selenium

As you are seeing NoSuchElementException you can consider using ...READ MORE

answered May 7, 2018 in Selenium by Samarpit
• 5,130 points
1,669 views