【问题标题】:Protractor handshake failed when connecting to local server with https protocol使用 https 协议连接到本地服务器时量角器握手失败
【发布时间】:2019-07-12 09:47:12
【问题描述】:

我正在尝试编写量角器测试,但我的应用程序连接到 WLS 服务器,该服务器使用 TEST 证书进行身份验证以进行进一步的通信。

由于我的公司政策,我没有更新 webdriver 的选项。所以我已经下载了 chrome 驱动程序并使用它。

量角器:5.4.2

铬:74.0.3729.169

Chrome 驱动程序:chromedriver_74.0.3729.6_win32

// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts

const {SpecReporter} = require('jasmine-spec-reporter');

exports.config = {
  allScriptsTimeout: 30000,
  chromeDriver: '../lib/chromedriver_74.0.3729.6_win32.exe',
  specs: [
    './src/**/*.e2e-spec.ts'
  ],
  capabilities: {
    'browserName': 'chrome',
    'acceptInsecureCerts': true,
    'acceptSslCerts': true,
    chromeOptions: {
      useAutomationExtension: false,
      args: ['--headless']
    }
  },
  framework: 'jasmine',
  directConnect: true,
  troubleshoot: true,
  jasmineNodeOpts: {
    showTiming: true,
    showColors: true,
    defaultTimeoutInterval: 2500000,
    print: function () {
    }
  },
  onPrepare: function () {
    require('ts-node').register({
      project: require('path').join(__dirname, './tsconfig.e2e.json')
    });
    jasmine.getEnv().addReporter(new SpecReporter({spec: {displayStacktrace: true}}));
  }
};

但我收到如下错误:

[0712/104633.475:ERROR:ssl_client_socket_impl.cc(946)] 握手 失败的;返回 -1,SSL 错误代码 1,net_error -117 [0712/104633.548:INFO:CONSOLE(27396)] "Http 失败响应 https://localhost:25000/app/api/disciplines: 0 未知错误”,来源: http://localhost:8082/app/main.js (27396)

【问题讨论】:

  • 你如何运行测试?你在angular.json 里有什么?会不会和CORS有关?
  • 不,它不是 CORS。它没有获得认证的测试证书,我觉得是这样。

标签: protractor angular-cli e2e-testing


【解决方案1】:

尝试将--allow-insecure-localhost 和/或--ignore-certificate-errors 添加到args 数组中。

  chromeOptions: {
    args: [
      '--headless',
      '--ignore-certificate-errors',
      '--allow-insecure-localhost'
    ]
  }

【讨论】:

    【解决方案2】:

    我可以通过以下方法解决它:

    AutoSelectCertificateForUrls

    通过编辑注册表,我能够停止弹出窗口并进行自动选择,并且可以成功运行我的测试。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-10
      • 2020-04-10
      • 1970-01-01
      • 1970-01-01
      • 2019-08-02
      • 2019-01-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多