Protractor 在windows中运行量角器测试
我试图在Windows中运行一些量角器测试,但出现以下错误:Protractor 在windows中运行量角器测试,protractor,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
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)
以前有人见过这个吗
更新:
量角器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才能成功安装量角器(即使我正在运行Windows 8)我已经确定是配置文件的“插件”部分导致了问题。如果我把它完全注释掉,测试就会运行 如果我将其更改为以下内容,它们也会运行:
plugins: [{
timeline: {
path: '../../../node_modules/protractor/plugins/timeline/',
// Output json and html will go in this folder.
outdir: 'timelines'
}
}]
唯一的变化是我已经将插件添加到了一个数组对象中。我是在看了量角器的“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的请提供您的量角器配置。我已经添加了配置文件-谢谢
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));
});
};