Selenium ChromeOptions 首选项默认的 OpenFileDialog Directory



我可以使用:

chromeOptions.AddUserProfilePreference("download.default_directory", downloadDirectory);

设置默认下载目录,但我似乎无法弄清楚设置默认打开文件目录的 prefs 键是什么。

我尝试查找所有可能的首选项列表。

使用 chrome 自动下载 PDF 的示例:

var options = new ChromeOptions();
options.AddUserProfilePreference("download.default_directory", "c:\Download");
options.AddUserProfilePreference("download.directory_upgrade", true);
options.AddUserProfilePreference("download.prompt_for_download", false);
options.AddUserProfilePreference("plugins.plugins_disabled", new []{"Chrome PDF Viewer"});
var service = ChromeDriverService.CreateDefaultService();
var driver = new ChromeDriver(service, options);

最新更新