How to download a pdf file in chrome using selenium webdriver

前端 未结 5 916
生来不讨喜
生来不讨喜 2020-11-30 14:33

I want to download pdf in chrome using selenium.

System.setProperty(\"webdriver.chrome.driver\", System.getProperty(\"user.dir\")  
               + System.         


        
5条回答
  •  渐次进展
    2020-11-30 14:54

    Here are the C# options for anyone working with .NET

    var tsTimeout = new TimeSpan(0, 5, 0);
    
    ChromeOptions chromeOptions = new ChromeOptions(); 
    chromeOptions.AddUserProfilePreference("download.default_directory", _downloadFolder); 
    chromeOptions.AddUserProfilePreference("download.prompt_for_download", false); 
    chromeOptions.AddUserProfilePreference("download.directory_upgrade", true); 
    chromeOptions.AddUserProfilePreference("plugins.plugins_disabled", "Chrome PDF Viewer"); 
    chromeOptions.AddUserProfilePreference("plugins.always_open_pdf_externally", true);
    
    _driver = new ChromeDriver(CWebCrawler.WebCrawlerRootFolder, chromeOptions, tsTimeout);
    

提交回复
热议问题