asked this question earlier, but now i will ask again with bit more explanation of what i did, I could not get it worked please help me out.

I am trying to download a file which is having a .exe extension but it is actually showing as a binary file (MIME type is application/octet-stream ) when i checked the GET request from the server, and i wrote the below code for setting up the firefox preferences which included binary file too.

firefoxProfile.setPreference("browser.download.folderList", 2);
        firefoxProfile.setPreference("browser.helperApps.neverAsksaveToDisk", "application/x-msexcel,text/html,application/xop+xml,application/vnd.ms-excel.sheet.binary.macroenabled.12,application/vnd.wap.wbxml,application/octet-stream,application/x-authorware-bin,application/x-bcpio,text/plain,application/x-msdownload,application/excel,application/x-excel,application/excel,application/x-excel,application/excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel");
    firefoxProfile.setPreference("browser.download.manager.showWhenStarting", false);

        firefoxProfile.setPreference("browser.download.dir", "C:\\Users\\Downloads");
firefoxProfile.setPreference("browser.privatebrowsing.autostart", true);
    GlobalVariables.BrowserDriver = new FirefoxDriver(firefoxProfile);

when i click the link for downloading, it is still asking for the save message, and the confusing part is at this stage i opened another tab in firefox and checked the preferences and its all set as false. that means the code part is working to set up preferences but save pop up message is still coming, i have no idea what is the problem here. If someone knows please guide me,


  • It is a duplicate but not answered yet, even though my comment on the other one should be the eventual answer. If you provide more specifics on how the popup itself is being generated we can answer that for you, but it really depends on the way it's being generated as if it's a browser control or custom code. Browser settings only take you so far...
    – mutt
    May 17 '17 at 20:05
  • Hi Mutt, i will try to give that, sorry for late reply, :)
    – sarath
    May 29 '17 at 18:54

Instead of avoiding it why not just handle the popup window and click the appropriate button? You can find the popup by iterating through the window handles, have the driver switch focus to it, and click the the appropriate button.

See here for actual code example



Not the answer you're looking for? Browse other questions tagged or ask your own question.