如何下载PDF selenium和C#

如何下载PDF selenium和C#,c#,selenium,selenium-webdriver,C#,Selenium,Selenium Webdriver,我确实在Chrome上安装了这个配置 ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.AddUserProfilePreference("download.default_directory", @"C:\Downloads"); Driver.driver = new ChromeDriver(chromeOptions);

我确实在Chrome上安装了这个配置

        ChromeOptions chromeOptions = new ChromeOptions();

        chromeOptions.AddUserProfilePreference("download.default_directory", @"C:\Downloads");
        Driver.driver = new ChromeDriver(chromeOptions);
PDF正在浏览器的“其他”选项卡中打开,我没有要下载的按钮

我无法按id对元素进行clic

        ActionsSU.moveElementToClick(By.XPath("/html/body"));
        ActionsSU.moveElementToClick(By.Id("download"));
我有解决办法

        chromeOptions.AddUserProfilePreference("download.default_directory", @"C:\Downloads");
        chromeOptions.AddUserProfilePreference("download.prompt_for_download", false);
        chromeOptions.AddUserProfilePreference("download.directory_upgrade", true);
        chromeOptions.AddUserProfilePreference("plugins.always_open_pdf_externally", true);