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,320 points
1,471 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,910 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,500 points

edited Apr 4, 2018 by nsv999 7,444 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 13, 2018 in Selenium by nsv999
• 5,500 points
6,184 views
0 votes
1 answer
0 votes
2 answers

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,500 points
13,649 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,131 views
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,910 points
7,209 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,865 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,910 points
7,774 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,910 points
8,269 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP