Frameworks 量角器测试未运行
我正在使用量角器-黄瓜框架,无法运行测试。浏览器已启动但未导航到我的URL,然后我收到以下错误:Frameworks 量角器测试未运行,frameworks,protractor,cucumber,Frameworks,Protractor,Cucumber,我正在使用量角器-黄瓜框架,无法运行测试。浏览器已启动但未导航到我的URL,然后我收到以下错误: $ protractor conf.js (node:10648) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead. [11:25:05] I/hosted - Using the selenium server at http://127.0.0.1:4444/wd/hub [11:25:05] I/la
$ protractor conf.js
(node:10648) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[11:25:05] I/hosted - Using the selenium server at http://127.0.0.1:4444/wd/hub
[11:25:05] I/launcher - Running 1 instances of WebDriver
[11:25:09] E/launcher - Error: TypeError: Cannot call a class as a function
at exports.default (C:\Source\test\node_modules\babel-runtime\helpers\classCallCheck.js:7:11)
at Object.Cli (C:\Source\test\node_modules\cucumber\lib\cli\index.js:64:34)
at C:\Source\test\node_modules\protractor-cucumber-framework\index.js:31:16
at Function.promise (C:\Source\test\node_modules\q\q.js:682:9)
at C:\Source\test\node_modules\protractor-cucumber-framework\index.js:24:14
at _fulfilled (\\hermes\vhd_profiles\VDI_Home_VHD1\modisej\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (\\hermes\vhd_profiles\VDI_Home_VHD1\modisej\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (\\hermes\vhd_profiles\VDI_Home_VHD1\modisej\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:796:13)
at \\hermes\vhd_profiles\VDI_Home_VHD1\modisej\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:556:49
at runSingle (\\hermes\vhd_profiles\VDI_Home_VHD1\modisej\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:137:13)
at flush (\\hermes\vhd_profiles\VDI_Home_VHD1\modisej\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
[11:25:09] E/launcher - Process exited with error code 100
Conf.js
exports.config = {
seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
//// getPageTimeout: 60000,
////allScriptsTimeout: 500000,
framework: 'custom',
// path relative to the current config file
frameworkPath: require.resolve('protractor-cucumber-framework'),
capabilities: {
'browserName': 'chrome'
},
// Spec patterns are relative to this directory.
specs: ['Features/*.feature'],
baseURL: 'http://localhost:/8080',
cucumberOpts: {
require: 'Features/step_definitions/homePage.js',
tags: false,
format: undefined,
profile: false,
'no-source': true
}
};
功能文件:
#features/test.feature
Feature: App hub home page
Scenario: First sample
Given I go to the app hub site
When the homepage has loaded
Then I expect to see title app hub
步骤定义:
exports.config = {
seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
//// getPageTimeout: 60000,
////allScriptsTimeout: 500000,
framework: 'custom',
// path relative to the current config file
frameworkPath: require.resolve('protractor-cucumber-framework'),
capabilities: {
'browserName': 'chrome'
},
// Spec patterns are relative to this directory.
specs: ['Features/*.feature'],
baseURL: 'http://localhost:/8080',
cucumberOpts: {
require: 'Features/step_definitions/homePage.js',
tags: false,
format: undefined,
profile: false,
'no-source': true
}
};
目前,我只为语句“给定我转到AppHub站点”添加了步骤定义
步骤定义保存在conf.js文件中提到的“Features”文件夹中名为“步骤定义”的文件夹中
module.exports = function() {
this.Given('I go to the app hub site', function (callback) {
browser.get('http://localhost:8080')
.then (callback);
});
};
任何帮助都将不胜感激 可能是不匹配的软件包版本导致了问题。当你运行npm列表时,你会得到什么 我目前在package.json中有以下内容:
"devDependencies": {
"chai": "^3.5.0",
"chai-as-promised": "^5.3.0",
"chai-string": "^1.2.0",
"cucumber": "^1.0.0",
"gulp": "^3.9.1",
"gulp-angular-protractor": "^0.1.1",
"protractor": "^3.3.0",
"protractor-cucumber-framework": "^0.6.0"
},
有了这些,我可以毫无困难地运行这些版本:
- 黄瓜-1.3.1
- 量角器框架-0.6.0
- 量角器-3.3.0
- 这很可能是错误,因为您正在将cucumber 2.0与量角器cucumber框架一起使用。目前它们不兼容,请将cucumber版本降级为1.3.1,这将解决您的问题
与此同时,在使用量角器Cumber框架支持Cumber2.0方面正在取得良好进展。您可以查看此回购-了解更多详细信息。太好了,谢谢您的帮助。我用的是Cucumber2.0。我在Drugator站点上找到了一个解决方法,并更改了我的config.js文件,使frameworkPath现在引用index.js文件,这很有效 Config.js
/protractor.conf.js
exports.config = {
seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
getPageTimeout: 60000,
allScriptsTimeout: 500000,
framework: 'custom',
// path relative to the current config file
frameworkPath: './index.js',
//frameworkPath: require.resolve('protractor-cucumber-framework'),
capabilities: {
'browserName': 'chrome'
},
useAllAngular2AppRoots: true,
// Spec patterns are relative to this directory.
specs: ['Features/*.feature'],
baseURL: 'http://localhost/',
cucumberOpts: {
require: 'Features/step_definitions/homePage.js',
tags: false,
format: undefined,
profile: false,
'no-source': true
}};
这是我的index.js文件 index.js`
var q = require('q'),
path = require('path'),
glob = require('glob'),
assign = require('object-assign'),
debug = require('debug')('protractor-cucumber-framework'),
Cucumber = require('cucumber'),
state = require('./lib/runState');
/*** Execute the Runner's test cases through Cucumber.
* @param {Runner} runner The current Protractor Runner.
* @param {Array} specs Array of Directory Path Strings.
* @return {q.Promise} Promise resolved with the test results
*/
exports.run = function(runner, specs) {
var results = {};
return runner.runTestPreparer().then(function() {
var config = runner.getConfig();
var opts = assign({}, config.cucumberOpts, config.capabilities.cucumberOpts);
state.initialize(runner, results, opts.strict);
return q.promise(function(resolve, reject) {
var cliArguments = convertOptionsToCliArguments(opts);
cliArguments.push('--require', path.resolve(__dirname, 'lib', 'resultsCapturer.js'));
cliArguments = cliArguments.concat(specs);
debug('cucumber command: "' + cliArguments.join(' ') + '"');
Cucumber.Cli(cliArguments).run(function (isSuccessful) {
try {
var complete = q();
if (runner.getConfig().onComplete) {
complete = q(runner.getConfig().onComplete());
}
complete.then(function() {
resolve(results);
});
} catch (err) {
reject(err);
}
});
});
});
function convertOptionsToCliArguments(options) {
var cliArguments = ['node', 'cucumberjs'];
for (var option in options) {
var cliArgumentValues = convertOptionValueToCliValues(option, options[option]);
if (Array.isArray(cliArgumentValues)) {
cliArgumentValues.forEach(function (value) {
cliArguments.push('--' + option, value);
});
} else if (cliArgumentValues) {
cliArguments.push('--' + option);
}
}
return cliArguments;
}
function convertRequireOptionValuesToCliValues(values) {
var configDir = runner.getConfig().configDir;
return toArray(values).map(function(path) {
// Handle glob matching
return glob.sync(path, {cwd: configDir});
}).reduce(function(opts, globPaths) {
// Combine paths into flattened array
return opts.concat(globPaths);
}, []).map(function(requirePath) {
// Resolve require absolute path
return path.resolve(configDir, requirePath);
}).filter(function(item, pos, orig) {
// Make sure requires are unique
return orig.indexOf(item) == pos;
});
}
function convertGenericOptionValuesToCliValues(values) {
if (values === true || !values) {
return values;
} else {
return toArray(values);
}
}
function convertOptionValueToCliValues(option, values) {
if (option === 'require') {
return convertRequireOptionValuesToCliValues(values);
} else {
return convertGenericOptionValuesToCliValues(values);
}
}
function toArray(values) {
return Array.isArray(values) ? values : [values];
}};
这不是一个解决方案,而是一个变通方法,使我能够成功运行测试。这里还有一个链接,该链接是使用typescript和cucumber的量角器cookbook示例的
包.json
。上面的错误是由于cucumber 2.0导致的,该版本尚未得到量角器cucumber框架的支持!这毫无意义。“./index.js”文件中有什么内容?