c# - 如何下载 PDF selenium 和 C#
问题描述
我确实在 Chrome 上放置了该配置
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddUserProfilePreference("download.default_directory", @"C:\Downloads");
Driver.driver = new ChromeDriver(chromeOptions);
PDF 正在浏览器中的其他选项卡中打开,我没有下载按钮。
我无法通过 id 在元素上单击。
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);
推荐阅读
- mysql - NodeJS 为什么我得到 SyntaxError: Invalid or unexpected token on a valid MySQL 查询?
- clojure - 如何在 clojure 中生成随机字母数字字符串?
- javascript - RxJS 在并行批量/队列中运行异步任务 Array.prototype.map
- spring - 如何在spring boot中上传带有产品数据的多部分文件
- installation - 启动 pgAdmin 4
- flutter - _InternalLinkedHashMap
' 不是类型 'List 的子类型 ' 尝试从 API 显示特定元素时抛出异常 - python - 'BinaryExpression' 对象和 'Comparator' 对象都没有属性 'days'
- google-apps-script - 如何将(PDF,二进制)文件从 GAS Web 服务到浏览器?
- javascript - 使用 html2Canvas 创建下载 png 时出现以下错误
- javascript - 从特定索引处的现有数组创建一个新数组