Search code examples
seleniumfirefoxmime

Selenium JS set_preference


I need to have selenium automation download a file using firefox. The automation successfully clicks the download, but a MIME opens to ask what to do. I need selenium to ignore this and just download the file.

Everything I have read days I should be able to use a function like this

const firefoxOption = new firefox.Options().set_preference(
 'browser.helperApps.neverAsk.saveToDisk',
 'application/zip,text/csv,text/txt',
);

But when I run this, it fails before it ever gets to clicking the download because this piece throws an error.

TypeError: (intermediate value).set_preference is not a function

what am I doing wrong??

ALL answers listed on SO show this exact code snippet and it is not working.


Solution

  • const firefoxOption = new firefox.Options().setPreference(
     'browser.helperApps.neverAsk.saveToDisk',
     'application/zip,text/csv,text/txt',
    );
    

    That method is for python

    https://www.selenium.dev/selenium/docs/api/javascript/module/selenium-webdriver/firefox_exports_Options.html