在Windows中运行量角器测试

时间:2015-05-07 17:07:40

标签: protractor

我正在尝试在Windows中运行一些量角器测试但是出现以下错误:

Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://10.44.10.127:55805/wd/hub
[launcher] Error: TypeError: Object #<Object> has no method 'forEach'
at new Plugins (C:\Users\user\AppData\Roaming\npm\node_modules\protractor\lib\plugins.js:30:20)
at driverprovider_.setupEnv.then.then.then.then.frameworkPath (C:\Users\ueser\AppData\Roaming\npm\node_modules\protractor\lib\runner.js:268:15)
at _fulfilled (C:\Users\user\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:797:54)
at self.promiseDispatch.done (C:\Users\user\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:826:30)
at Promise.promise.promiseDispatch (C:\Users\user\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:759:13)
at C:\Users\user\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:573:44
at flush (C:\Users\user\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:108:17)
at process._tickCallback (node.js:419:13)

然后

[launcher] Process exited with error code 100

以前有人遇到过这个吗?

更新

量角器conf.js文件如下:

'use strict';

var testConfig = require('../../testConfig');

exports.config = {
allScriptsTimeout: 11000,

suites: {
    dev: ['domain/**/*Spec.js', 'common/**/*Spec.js'],
    oldExtranetIntegration: ['integration/**/*Spec.js']
},

baseUrl: testConfig.baseUrl,

framework: 'jasmine',

onPrepare: function () {

    /* global angular: false, browser: false, document: false */

    // Disable animations so e2e tests run more quickly
    var disableNgAnimate = function () {
        angular.module('disableNgAnimate', []).run(function () {
            var css = document.createElement('style');
            css.type = 'text/css';
            css.innerHTML = '* { -webkit-transition-duration: 5ms !important; transition-duration: 5ms !important; -webkit-animation-duration: 5ms !important; animation-duration: 5ms !important; }';
            document.body.appendChild(css);
        });
    };

    browser.addMockModule('disableNgAnimate', disableNgAnimate);
},

// Disabled settings for using chromedriver directly
//directConnect: true,
//chromedriver: '/node_modules/chromedriver/lib/chromedriver/chromedriver',

capabilities: {
    browserName: 'phantomjs',
    'phantomjs.binary.path': require('phantomjs').path
},

jasmineNodeOpts: {
    defaultTimeoutInterval: 30000,
    isVerbose: true
},

plugins: {
    timeline: {
        path: '../../../node_modules/protractor/plugins/timeline/',

        // Output json and html will go in this folder.
        outdir: 'timelines'
    }
}

};

另请注意,我们的Linux机器上的测试运行正常。我必须安装Windows SDK 7.1才能成功安装Protractor(即使我正在运行Windows 8)

1 个答案:

答案 0 :(得分:1)

我发现它是导致问题的配置文件的“插件”部分。如果我完全评论它,测试运行。

如果我将其更改为以下内容,它们也会运行:

plugins: [{
    timeline: {
        path: '../../../node_modules/protractor/plugins/timeline/',

        // Output json and html will go in this folder.
        outdir: 'timelines'
    }
}]

唯一的变化是我已将插件添加到数组对象中。我在查看Protractor的“plugins.js”代码之后做了这个:

var Plugins = function(config) {
    var self = this;

    this.pluginConfs = config.plugins || [];
    this.pluginObjs = [];
    this.pluginConfs.forEach(function(pluginConf) {
      var path;
      if (pluginConf.path) {
        path = ConfigParser.resolveFilePatterns(pluginConf.path, true,
          config.configDir)[0];
      } else {
        path = pluginConf.package;
      }
      if (!path) {
          throw new Error('Plugin configuration did not contain a valid path.');
      }
      pluginConf.name = path;
      self.pluginObjs.push(require(path));
    });
};

在没有阵列的情况下,Linux(Ubuntu)上的测试运行良好,但在Windows中运行需要它。

这都是由于安装了量角器v1.5,当测试和配置文件用于量角器v1.3时

相关问题