0

I'm trying to make very simple cucumber with protractor example ,but get errors in feature file ,Here is my code

protractor.conf.js file

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 file

 Feature: Running Protractor and Cucumber

 Scenario: Protractor and Cucumber Test
    Given I go to home page

stepDefinition js file

 module.exports = function() {

this.Given(/^I go to home page$/, function(site, callback) {
  browser.get(site)
  .then(callback);
});

}

but when i going to run by $ gulp protractor I get the following error

 [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

Can anyone please help me to fix the error?

Ali-Alrabi
  • 1,515
  • 6
  • 27
  • 60
  • This error is likely due to you are using older version of node with newer version of protractor. If you are using latest protractor 5.1 version, your node version should be atleast v 6.9.x – Ram Pasala Apr 26 '17 at 18:08
  • node version is v6.10.2 and protractor version is Version 5.1.1 – Ali-Alrabi Apr 26 '17 at 21:13
  • Did you already fix this because you also have a question about [generating a report](http://stackoverflow.com/questions/43697992/serentiy-report-with-protracor-and-cucumber) which assumes you got it working, or are those not related? – wswebcreation Apr 29 '17 at 18:20

1 Answers1

0

You need to set the framework to custom as shown here. It defaults to jasmine which is what is trying to execute that feature file.

Darrin Holst
  • 696
  • 5
  • 7