允许在ChromeDriver中进行多次下载

Ale*_*chi 5 c# selenium google-chrome selenium-chromedriver selenium-webdriver

我需要使用ChromeDriver(C#)在Chrome中下载多个文件,第一个文件下载成功,但是其他人没有下载,出现了一个窗口询问"下载多个文件 - 允许|阻止"

我需要配置自动下载.在Chrome的偏好设置中有"设置 - >内容设置 - >自动下载 - >允许所有网站自动下载多个文件"选项

我需要在示例中配置"ChromeOptions"

var options = new ChromeOptions();
options.AddUserProfilePreference("...", true);
Run Code Online (Sandbox Code Playgroud)

以下是Chrome消息的图片

Chrome消息窗口

Ale*_*chi 13

我找到了解决方案.只需添加首选项:

var options = new ChromeOptions();
options.AddUserProfilePreference("profile.default_content_setting_values.automatic_downloads", 1);
Run Code Online (Sandbox Code Playgroud)