Firefox + Selenium WebDriver and download a csv file automatically

后端 未结 3 805
野的像风
野的像风 2020-12-10 14:59

I have problem with Selenium WebDriver and Firefox. I want to download csv file without confirmation in dialog window and I have code like this:

fp = webdriv         


        
相关标签:
3条回答
  • 2020-12-10 15:37

    Now (May 2016),

     SetPreference("browser.helperApps.neverAsk.saveToDisk", "text/csv"); // C#
    

    works for me

    0 讨论(0)
  • 2020-12-10 15:41

    SetPreference("browser.helperApps.neverAsk.saveToDisk", "application/comma-separated-values ,text/csv"); //in java selenium this will work for downloading all type of csv files... thanks, enjoy....

    0 讨论(0)
  • 2020-12-10 15:43

    Sometime the content type is not as you'd expect Use HttpFox Firefox plugin (or similar) to find the real content type of the file and use it in your code

    BTW, For me the content type was

    fp.set_preference("browser.helperApps.neverAsk.openFile", "application/octet-stream");
    fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream");
    
    0 讨论(0)
提交回复
热议问题