如何在空手道 UI 测试中启用 acceptInsecureCerts

How to enable acceptInsecureCerts on Karate UI test

我正在尝试为我的网页编写一个空手道 UI 测试,该网页目前有一个自签名证书,因此默认情况下被浏览器阻止。 According to the documentation,当启用 acceptInsecureCerts 参数时,应绕过此检查。但是我找不到将此参数传递给驱动程序的正确语法。这是我的(简化的)特征文件:

Feature: browser automation 1

  Background:
    * def session = { capabilities: { acceptInsecureCerts: true } }
    * configure driver = { type: 'chrome', showDriverLog: true, showProcessLog: true, showBrowserLog: true, webDriverSession: '#(session)' }

  Scenario: load demo page
    Given driver 'https://127.0.0.1:8443/demo'
    * waitUntil('document.readyState == "complete"')
    * print 'page loaded'
    * screenshot()
    Then delay(2000).text('body')

当我运行这个时,我得到

13:31:25.237 [nioEventLoopGroup-2-1] DEBUG c.intuit.karate.driver.DriverOptions - << {"id":9,"result":{"result":{"type":"string","value":"Your connection is not private Attackers might be trying to steal your information from ...

稍等,chrome 不是基于网络驱动程序的,因此 webDriverSession 将不适用。 chromedriver.

我快速搜索了一下,我能找到的最好的是:ignore-certificate-errors + headless puppeteer+google cloud

所以不确定这是否有效:

addOptions: ['--ignore-certificate-errors']

请报告您的发现,以帮助他人!另一个参考是这个,但不确定它是如何更新的:https://peter.sh/experiments/chromium-command-line-switches