gulp-量角器错误 chrome v54 / 网络驱动程序 v2.25

gulp-protractor error with chrome v54 / web driver v2.25

由于 chrome (v54) 的最新更新,我们注意到我们的量角器测试失败了。我们尝试更新到最新版本的 gulp-protractor (v3.0.0),它会下载最新的网络驱动程序 (v2.25) 来解决问题,但不幸的是出现了一个新错误,我们无法解决解决。

在 chrome 更新之前一切正常。

我们的量角器配置如下:

exports.config = {
  // Capabilities to be passed to the webdriver instance.
  capabilities: {
    'browserName': 'chrome'
  },

  onPrepare: function () {
      var fs = require('fs');
      var testDir = 'testresults/';
      if (!fs.existsSync(testDir)) {
          fs.mkdirSync(testDir);
      }

      var jasmineReporters = require('jasmine-reporters');

      // returning the promise makes protractor wait for the reporter config before executing tests
      return browser.getProcessedConfig().then(function () {
          // you could use other properties here if you want, such as platform and version

          var browserName = 'browser';
          browser.getCapabilities().then(function (caps) {
              browserName = caps.caps_.browserName.replace(/ /g, "_");

              var junitReporter = new jasmineReporters.JUnitXmlReporter({
                  consolidateAll: true,
                  savePath: testDir,
                  // this will produce distinct xml files for each capability
                  filePrefix: 'test-protractor-' + browserName,
                  modifySuiteName: function (generatedSuiteName) {
                      // this will produce distinct suite names for each capability,
                      // e.g. 'firefox.login tests' and 'chrome.login tests'
                      return 'test-protractor-' + browserName + '.' + generatedSuiteName;
                  }
              });
              jasmine.getEnv().addReporter(junitReporter);
          });
      });
  },

  baseUrl: 'http://localhost:3000',

  // Spec patterns are relative to the current working directory when
  // protractor is called.
  specs: [paths.e2e + '/**/*.js'],

  // Options to be passed to Jasmine-node.
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000
  }
};

错误是:

[13:27:13] E/launcher - Error: Error
    at C:\ws\node_modules\protractor\built\util.js:55:37
    at _rejected (C:\ws\node_modules\q\q.js:844:24)
    at C:\ws\node_modules\q\q.js:870:30
    at Promise.when (C:\ws\node_modules\q\q.js:1122:31)
    at Promise.promise.promiseDispatch (C:\ws\node_modules\q\q.js:788:41)
    at C:\ws\node_modules\q\q.js:604:44
    at runSingle (C:\ws\node_modules\q\q.js:137:13)
    at flush (C:\ws\node_modules\q\q.js:125:13)
    at nextTickCallbackWith0Args (node.js:420:9)
    at process._tickCallback (node.js:349:13)
[13:27:13] E/launcher - Process exited with error code 100

onPrepare 正在 built/util.js 的 runFilenameOrFn_ 函数中进行评估。不幸的是,堆栈跟踪没有帮助,但这意味着 onPrepare 有错误。查看您的 onPrepare 方法,从浏览器功能分配 browserName 时出错。在您的代码中, caps.caps_ 实际上是未定义的。因为 caps.caps_ 未定义,所以 caps.caps_.browserName 抛出错误。应按以下方式访问功能对象:

browser.getCapabilities().then(capabilities => {
  let browserName = capabilities.browserName.replace(/ /g, "_");