chrome v54 / web driver v2.25的gulp-protractor错误

时间:2016-10-27 23:16:19

标签: google-chrome gulp protractor chrome-web-driver gulp-protractor

由于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

1 个答案:

答案 0 :(得分:2)

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

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