Я испробовал все возможные способы загрузки отчета PDF из Chrome, не открывая новую вкладку PDF Viewer. Я хочу скачать PDF прямо на свой локальный диск. Я использую Coypu для разработки моей инфраструктуры автоматизации
Код, который я использую, выглядит следующим образом:
BrowserSession _session;
ChromeOptions options = new ChromeOptions();
String downloadFilepath = @"C:\Users\3682143\Downloads";
Dictionary<String,Object> chromeOptionsMap = new Dictionary<String, Object>();
chromeOptionsMap.Add("plugins.plugins_disabled", new String[] {"Chrome PDF Viewer"});
chromeOptionsMap.Add("download.default_directory", downloadFilepath);
chromeOptionsMap.Add("plugins.always_open_pdf_externally", true);
chromeOptionsMap.Add("download.prompt_for_download", false);
chromeOptionsMap.Add("pdfjs.disabled", true);
options. AddUserProfilePreference("prefs", chromeOptionsMap);
DesiredCapabilities desiredCap = DesiredCapabilities.Chrome();
desiredCap.SetCapability(CapabilityType.AcceptSslCertificates, true);
desiredCap.SetCapability(ChromeOptions.Capability, options);
_session = new BrowserSession(sessionConfig, new CustomExplorerProfileSeleniumWebDriver(desiredCap));