我用的是量角器-黄瓜框架不能运行我的测试。启动浏览器,但不导航到我的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/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 100Conf.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步骤定义:
目前,我只对语句“假设我进入应用中心站点”进行了分步定义。
step_definitions保存在我在conf.js文件中提到的“特性”文件夹中的一个名为“step_definitions”的文件夹中。
module.exports = function() {
this.Given('I go to the app hub site', function (callback) {
browser.get('http://localhost:8080')
.then (callback);
});
};任何帮助都将不胜感激。
发布于 2017-01-13 21:26:20
这是最有可能的错误,因为您使用的黄瓜2.0与量角器-黄瓜-框架。目前,它们是不兼容的,请将您的黄瓜版本降到1.3.1,这将解决您的问题。
同时,用量角器-黄瓜框架支持黄瓜2.0也取得了很好的进展.您可以查看这个回购- 量角器-黄瓜-框架的更多细节。
发布于 2017-01-13 14:17:57
它可能是不匹配的软件包版本,造成麻烦。当您运行npm list <package-name>时,您得到了什么?
我目前在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"
},有了这些版本,我就可以顺利地运行这些版本了:
发布于 2017-01-18 10:47:30
很好,谢谢你的帮助。我使用的是黄瓜2.0。我在量角器站点上找到了一个解决办法,并更改了我的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
}};https://stackoverflow.com/questions/41635806
复制相似问题