量角器功能测试无法加载不安全的 http javascript

Protractor functional test cannot load unsafe http javascript

所以我写了一个 bookmarklet 并想做一些功能测试,我使用了 Protractor 并且我能够将我的 bookmarklet javascript 文件注入它。但是,由于它是在本地托管的,因此它不是 HTTPS。当我 运行 测试时,尽管注入了 js 文件,但我得到了

VM122:17 Mixed Content: The page at 'https://xxxx' was loaded over HTTPS, but requested an insecure script 'http://localhost:8000/content.js'. This request has been blocked; the content must be served over HTTPS.

由于每次测试时都会新建浏览器 运行s 我无法设置 'load unsafe script option' 进行测试。

您可以在量角器配置中使用额外参数启动 chromedriver。

capabilities: {
    browserName: "chrome",
    chromeOptions: {
        args: [
            "--allow-running-insecure-content"
        ]
    }
}

有关 chromedriver 参数的完整列表,请参阅: