我正在尝试使用 Python Selenium 下载文件;试图找出一种方法来控制下载文件时显示在屏幕底部的黄色通用下载提示。有没有一种方法可以使用 Selenium 点击“另存为”并使用 Selenium 和相同的驱动程序 session 保存文件。
最佳答案
您可以修改您的驱动程序下载设置,例如使用 firefox。当请求下载文件时,它不会创建弹出窗口,而是保存在您在下面指定的位置。
FirefoxProfile fxProfile = new FirefoxProfile();
fxProfile.setPreference("browser.download.folderList",2);
fxProfile.setPreference("browser.download.manager.showWhenStarting",false);
fxProfile.setPreference("browser.download.dir","c:\\mydownloads");
fxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk","text/csv");
WebDriver driver = new FirefoxDriver(fxProfile);
https://stackoverflow.com/questions/61325484/
相关文章:
amazon-web-services - 注册到 AWS Chime session 通知
c# - Blazor + MongoDb 身份 : Value cannot be null.(参
wordpress - 全局禁用 WP Gutenberg 预发布检查
reactjs - 为什么在主题 UI 上使用 Rebass?
windows - 如何使用 ssh 将 git push 到远程 Windows 机器
reactjs - 为什么 react-router 在调度时自动返回到以前的路由