Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

Is there any kind of API that can allow me to manipulate a file download dialog in Firefox? (I want to access the one that appears when a user does something, not initiate one myself).

What I want to do is to access this dialog from Selenium (and whether Selenium "privileged mode" is enough to access chrome interface is something I am not sure about as well).

1 Answer

0 votes
by (62.9k points)

In the application, the instance of FireFox was created by passing the DesiredCapabilities as follows

driver = new FirefoxDriver(capabilities);

Based on the suggestions by others, I did my changes as:

FirefoxProfile firefoxProfile = new FirefoxProfile();     

firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk",

    "application/octet-stream");

driver = new FirefoxDriver(firefoxProfile);

This served the purpose but unfortunately, my other automation tests started failing. And the reason was, I have removed the capabilities which were being passed earlier.

There is an alternate way, through which we can set the profile itself in the desired Capabilities.

So the new working code looks like

DesiredCapabilities capabilities = DesiredCapabilities.firefox();

// add more capabilities as per your need.

FirefoxProfile firefoxProfile = new FirefoxProfile();        

firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk",

    "application/octet-stream");

// set the firefox profile as a capability

capabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile);

driver = new FirefoxDriver(capabilities);

Hope this code helps you! 

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...