Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
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! 

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.1k users

Browse Categories

...