我尝试使用量角器示例实现非常简单的黄瓜,但在功能文件中出错,这是我的代码
我正在使用节点版本v6.10.2,量角器版本5.1.1和黄瓜版本2.4.0
protractor.conf.js文件
var prefix = 'src/test/javascript/'.replace(/[^/]+/g,'..');
exports.config = {
seleniumServerJar: prefix + 'node_modules/protractor/selenium/selenium-server-standalone-2.52.0.jar',
chromeDriver: prefix + 'node_modules/protractor/selenium/chromedriver',
allScriptsTimeout: 20000,
frameworkPath: require.resolve('protractor-cucumber-framework'),
directConnect: true,
baseUrl: 'http://localhost:8099/',
cucumberOpts: {
require: 'step_definitions/stepDefinitions.js',
format: 'summary'
},
specs: [
'features/*.feature'
]
};
获取错误的要素文件
Feature: Running Protractor and Cucumber
Scenario: Protractor and Cucumber Test
Given I go to home page
stepDefinition js文件
module.exports = function() {
this.Given(/^I go to home page$/, function(site, callback) {
browser.get(site)
.then(callback);
});
}
但是当我要用$ gulp量角器运行时,我得到以下错误
[16:01:21] Using gulpfile ~/git/adap_gateway/gulpfile.js
[16:01:21] Starting 'protractor'...
Using ChromeDriver directly...
[launcher] Running 1 instances of WebDriver
[launcher] Error: /home/ali/git/adap_gateway/src/test/javascript/features
/attack.feature:1
(function (exports, require, module, __filename, __dirname) { Feature:
Running Protractor and Cucumber
^^^^^^^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at /home/ali/git/adap_gateway/node_modules/jasmine/lib/jasmine.js:71:5
[launcher] Process exited with error code 100
[16:01:21] gulp-notify: [JHipster Gulp Build] Error: protractor exited
with code 100
[16:01:22] Finished 'protractor' after 936 ms
[16:01:22] E2E Tests failed
有人可以帮我修复错误吗?
答案 0 :(得分:1)
也许您可以尝试将framework
属性设置为' custom'而不是要求cucumber-protractor-framework
。
我使用相同的堆栈,这是我的配置:
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
希望这会对你有所帮助。