【问题标题】:C# Selenium Chrome Add URLs to Insecure ContentC# Selenium Chrome 将 URL 添加到不安全的内容
【发布时间】:2020-09-25 05:48:47
【问题描述】:

我需要将站点 URL 添加到允许不安全内容的站点列表中。我终其一生都找不到关于这个主题的任何东西。我能够执行类似的操作来添加 URL 列表以允许 Flash,但无法让 Chrome 特定的设置语法适用于不安全的内容选项卡。这是我用来获取允许的 Flash 设置的 URL 列表的代码:

var service = ChromeDriverService.CreateDefaultService(seleniumLocation);
var options = new ChromeOptions();
List<string> flashUrls = new List<string>() { 
       "https://www.someplace.com","https://www.someotherplace.com" };
options.AddUserProfilePreference("profile.managed_plugins_allowed_for_urls", flashUrls);
IWebDriver driver = new ChromeDriver(service, options);

效果很好。我已经为不安全的内容尝试了不同的变体,但没有一个能够添加 URL。

List<string> insecureUrls = new List<string>() { 
     "https://www.someplace.com","https://www.someotherplace.com" };
options.AddUserProfilePreference("profile.insecure_content_allowed_for_urls", insecureUrls);

我很确定 profile.insecure_content_allowed_for_urls 部分出了什么问题,但在任何地方都找不到关于它应该是什么的任何信息。下面是 Chrome 中设置的截图。

【问题讨论】:

    标签: c# selenium selenium-chromedriver


    【解决方案1】:

    我为以后发现此问题的任何人找到了答案。 managed_insecure_content_allowed_for_urls 是正确的语法。

    List<string> insecureUrls = new List<string>() {  "https://www.someplace.com" };
    options.AddUserProfilePreference("profile.managed_insecure_content_allowed_for_urls", insecureUrls);
    

    【讨论】:

      猜你喜欢
      • 2017-09-30
      • 2013-01-08
      • 1970-01-01
      • 2013-08-09
      • 2013-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多