【问题标题】:AutoSelectCertificateForUrls for Chrome works ONLY in non-headless modeChrome 的 AutoSelectCertificateForUrls 仅在非无头模式下工作
【发布时间】:2019-09-27 16:31:25
【问题描述】:

我正在使用以下首选项文件为 MacOS 上的 Chrome 自动选择证书:

<plist version="1.0″>
<dict>
  <key>AutoSelectCertificateForUrls</key>
   <array>
     <string>{"pattern":"[*.]my.url.net","filter":{"ISSUER":{"CN":"CERT CA"}}}</string>
   </array>
</dict>
</plist>

效果很好,但是当我尝试使用 headless 模式在 Chrome 上运行测试时,它似乎没有自动选择证书。

有谁知道如何做到这一点?我正在使用以下 ChromeOptions

'chromeOptions': {
      'args': ['--ignore-certificate-errors', '--headless', '--disable-gpu', '--no-sandbox']
}

【问题讨论】:

    标签: javascript selenium google-chrome selenium-webdriver selenium-chromedriver


    【解决方案1】:

    headless chrome 不支持策略配置,如果 headless firefox 是一个选项,您可以使用 fireFoxOptions 来使用可以添加证书的配置文件。我需要自动选择证书并设法仅使用无头 Firefox 来完成。打开默认的 Firefox,设置您的配置文件,如果您不想手动操作,请在代码上指向它。

    FirefoxOptions options = new FirefoxOptions();
    FirefoxProfile firefoxProfile = new FirefoxProfile(@"C:\Users\....\AppData\Roaming\Mozilla\Firefox\Profiles\...default");
    options.Profile = firefoxProfile;
    

    【讨论】:

      猜你喜欢
      • 2021-11-06
      • 1970-01-01
      • 1970-01-01
      • 2020-06-12
      • 2018-08-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-18
      相关资源
      最近更新 更多