Search code examples
pythonseleniumgeckodriver

Where can I find arguments for options class for geckodriver?


I am using selenium with Python and firefox browser, I am trying to download a file and disable the pop up window that asks if I want to save it and where: enter image description here

Since FirefoxProfile and FirefoxOptions and deprecated in selenium 4.0.0 + , I am trying to use the Options() class to replace it

There are various arguments to be given to the option class, such as:

        options = Options()
    options.add_argument("--headless")

But I need the argument to disable the download window I attached above. I searched a lot and I can't find any documentation on the possible arguments you can pass to options.add_argument .

I've tried down grading to earlier version and add FirefoxProfile arguments such as:

profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream")

But it still doesn't work.

If any one can share a documentation specifying the possible arguments for options, or just the specific argument to disable this pop up - that would be great.

Thanks!


Solution

  • I have these preferences set in my framework and it works good so far

    profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/csv,application/excel,application/vnd.ms-excel,application/vnd.msexcel,text/anytext,text/comma-separated-values,text/csv,text/plain,text/x-csv,application/x-csv,text/x-comma-separated-values,text/tab-separated-values,data:text/csv")
    profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/xml,text/plain,text/xml,image/jpeg,application/octet-stream,data:text/csv")
    profile.set_preference("browser.download.manager.showWhenStarting",False)
    profile.set_preference("browser.helperApps.neverAsk.openFile","application/csv,application/excel,application/vnd.ms-excel,application/vnd.msexcel,text/anytext,text/comma-separated-values,text/csv,text/plain,text/x-csv,application/x-csv,text/x-comma-separated-values,text/tab-separated-values,data:text/csv")
    profile.set_preference("browser.helperApps.neverAsk.openFile","application/xml,text/plain,text/xml,image/jpeg,application/octet-stream,data:text/csv")
    profile.set_preference("browser.helperApps.alwaysAsk.force", False)
    profile.set_preference("browser.download.useDownloadDir", True)
    profile.set_preference("dom.file.createInChild", True)
    

    Possibly most of these settings will be redundant for you, but they may appear useful in the future.