No results from cucumber protractor run

596 Views Asked by At

I'm using protractor with Cucumber, first, without cucumber i succeeded to run tests, but soon as i have added via npm the cucumber support, i got results with undefined test, see below :

1 scenario (1 undefined)
3 steps (3 undefined)
0m00.000s
[15:04:58] I/launcher - 0 instance(s) of WebDriver still running
[15:04:58] I/launcher - chrome #01 passed
Process finished with exit code 0

which mean the chromeDriver starting and after few seconds closed, I have tried it on two project, one is on git: https://github.com/eis95/CucumberProtractorExample

so you can see how i defined the config and also the packages.js file, The package file:

{
  "name": "uiautomation-v2.0",
  "version": "0.0.0",
  "description": "UIAutomationV2.0",
  "main": "app.js",
  "author": {
    "name": "Eyal.Cohen"
  },
  "devDependencies": {
    "cucumber": "^2.3.1",
    "protractor-cucumber-framework": "^3.1.2"
  },
  "dependencies": {
    "@types/jasmine": "^2.5.53",
    "protractor": "latest"
  }
}


And the conf.js file:

    
        exports.config = {
    
          specs: ['features/**/*.feature'],
          //seleniumServerJar:'./node_modules/protractor/selenium/selenium-server-standalone-2.52.0.jar',
          //chromeDriver: './node_modules/protractor/selenium/chromedriver_2.21',
          seleniumAddress: 'http://localhost:4444/wd/hub',
    
          capabilities: {
            'browserName': 'chrome'
          },
    
          framework: 'custom',
          frameworkPath: require.resolve('protractor-cucumber-framework'),
    
          cucumberOpts: {
            tags: [],
            require: ['features/step_definitions/newGameSteps.js'], //'features/specSetup.js','features/**/step_definitions/**/*Steps.js'
            format: 'pretty'
          }
        };

Spec:

defineSupportCode(function({Given, When, Then}) {
    Given(/^Navigate to studio url$/, function(callback) {
        //callback(null, 'pending');
        navigationSteps.navigateToStudio(data.server).then(function() {
            loginPage.userName.isDisplyed();
        })
        callback();
    });
When(/^Login with username and pass$/, function(callback) {

    navigationSteps.loginToStudio(data.username, data.password).then(function () {
        navigationSteps.navigateUrl(data.server + '/studio/#/sxp?isautomation=true').then(function () {

        })
        callback();
    });
});

Then(/^Welcome page is displayed$/, function(callback) {

    sxpSteps.sendSxp(testData.requestNewTaskSxp).then(function () {

        navigationSteps.navigateToUrl(data.server + '/studio/#/schedule').then(callback)
    });
    callback();
});

});

Appreciate your help Thanks

1

There are 1 best solutions below

1
On BEST ANSWER

Based on your provided info something is wrong:

  • your package says you are using CucumberJS ^0.10.3
  • your step implementation suggests that you are using CucumberJS 2.x

So please fix that in your provided info ;-).

Having said that, the problem that you described / passing the promise can have to do with the fact you need to choose between returning callback's or promises, see the code example below.

It's never wise to pass values between steps, you should keep the values in the same scope.

// With callbacks
Then(/^Submit Button is disabled$/, function(done) {
  var searchButton = element(by.buttonText('Search'));
  return expect(searchButton.isEnabled()).to.eventually.equal(false).and.notify(done);
});

// With Promises
Then(/^Submit Button is disabled$/, function() {
  var searchButton = element(by.buttonText('Search'));
  return expect(searchButton.isEnabled()).to.eventually.equal(false);
});