Access to file download dialog in Firefox

前端 未结 11 2358
一个人的身影
一个人的身影 2020-11-22 07:02

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 user does something, not initiate one

11条回答
  •  隐瞒了意图╮
    2020-11-22 07:32

    I was stuck with the same problem, but I found a solution. I did it the same way as this blog did.

    Of course this was Java, I've translated it to Python:

    fp = webdriver.FirefoxProfile()
    
    fp.set_preference("browser.download.folderList",2)
    fp.set_preference("browser.download.manager.showWhenStarting",False)
    fp.set_preference("browser.download.dir",getcwd())
    fp.set_preference("browser.helperApps.neverAsk.saveToDisk","text/csv")
    
    browser = webdriver.Firefox(firefox_profile=fp)
    

    In my example it was a CSV file. But when you need more, there are stored in the ~/.mozilla/$USER_PROFILE/mimeTypes.rdf

提交回复
热议问题