【问题标题】:Protractor Chrome headless mixed content issueProtractor Chrome 无头混合内容问题
【发布时间】:2019-06-19 15:09:27
【问题描述】:

我正在自动化 AngularJS 网站,我需要使用无头 Protractor 运行 Selenium Chrome 驱动程序。问题是我在终端中遇到了这个错误:

Mixed Content: The page at 'https://x.com' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://y.com'. This request has been blocked; the content must be served over HTTPS.

我尝试在下面的代码中使用一些 Chrome 参数,但没有成功。但是,如果我删除无头 arg,它就可以工作。

capabilities: {
  browserName: 'chrome',
  acceptInsecureCerts : true,
  acceptSslCerts : true,
  chromeOptions: {
    args: [
      '--headless',
      '--disable-gpu',

      '--remember-cert-error-decisions',

      '--ignore-certificate-errors',
      '--reduce-security-for-testing',
      '--allow-running-insecure-content',

      '--window-size=800,600'
    ]
  },
},

【问题讨论】:

    标签: automation protractor selenium-chromedriver


    【解决方案1】:

    https://github.com/angular/protractor/blob/master/docs/browser-setup.md#using-headless-chrome

    capabilities: {
      browserName: 'chrome',
    
      chromeOptions: {
         args: [ "--headless", "--disable-gpu", "--window-size=800,600" ]
       }
    }
    

    三个以上的参数就足够在无头模式下运行了。

    尝试删除您功能中的其他参数

    【讨论】:

    【解决方案2】:

    我遇到了同样的问题。解决方法是在浏览器中点击网址右侧的“屏蔽”图标,然后点击“加载不安全脚本”

    这是非常相关的: How to get Chrome to allow mixed content?

    【讨论】:

      猜你喜欢
      • 2020-01-25
      • 1970-01-01
      • 2018-05-20
      • 2018-02-23
      • 2015-10-31
      • 2016-09-04
      • 2015-08-13
      • 2017-09-27
      • 1970-01-01
      相关资源
      最近更新 更多