mucsi96 / nightwatch-cucumber

[DEPRECATED] Cucumber.js plugin for Nightwatch.js.
http://mucsi96.github.io/nightwatch-cucumber
MIT License
236 stars 73 forks source link

strange behavior after update #72

Closed AlfredoMoretta closed 8 years ago

AlfredoMoretta commented 8 years ago

Using page-object tests after the last update of nightwatch after launching nightwatch -e chrome,the test don't start and i've this output :

Warnings:

1) Scenario: First try google - features/google.feature:4 Step: Given I open google home page - features/google.feature:6 Message: Undefined. Implement with the following snippet:

   this.Given(/^I open google home page$/, function (callback) {
     // Write code here that turns the phrase above into concrete actions
     callback(null, 'pending');
   });

is it possible that is a regression for the update?

thank you, Alfredo

mucsi96 commented 8 years ago

Thank you for the feedback! Can you provide a simple test case to reproduce the issue? It would be very helpfull.

Thanks Igor

mucsi96 commented 8 years ago

Because the page-obeject test associated with the build passed successfully

AlfredoMoretta commented 8 years ago

try with this: step.js: module.exports = function() { this.Given(/^I open home page$/, function () { this.page.homepageFooter.footerAboutClick()

})

this.Then(/^Then I click About on footer$/, function () { this.page.homepageFooter.footerPress()

}) };

and in page-object use homepageFooter.js that contains:

module.exports = function () { this.footerAboutClick = function() { browser .url("http://someurl") .waitForElementVisible('body', 10000) .windowMaximize() .refresh() .click(".someclass") .pause(1000) }

this.footerPress = function() { browser .click(".someclass") return browser } }

mucsi96 commented 8 years ago

@Alfredo81 your page-object definitions are wrong. Please read http://nightwatchjs.org/guide#page-objects A working example would be

#features/test.feature
Feature: Test feature
Scenario: Test scenario

  Given I open home page
  Then Then I click About on footer
//features/step_definitions/step.js
module.exports = function() {
  this.Given(/^I open home page$/, function() {
    var homepageFooter = this.page.homepageFooter();
    homepageFooter.footerAboutClick()

  })

  this.Then(/^Then I click About on footer$/, function() {
    var homepageFooter = this.page.homepageFooter();
    homepageFooter.footerPress()

  })
};
//page-objects/homepageFooter.js
var footerCommands = {
    footerAboutClick: function() {
      return this.api
        .url("http://google.com")
        .waitForElementVisible('body', 10000)
        .windowMaximize()
        .refresh()
        .click("input[type='submit']")
        .pause(1000);
    },
    footerPress: function() {
      return this
        .click("input[type='submit']")
    }
  }

module.exports = {
  commands: [footerCommands],
  elements: {}
}
AlfredoMoretta commented 8 years ago

@mucsi96 first of all thank you so much for your help Igor.Unfortunately for this example the output is: Running: Test Scenario Scenario: Test Scenario

[TypeError: homepageFooter.footerAboutClick is not a function] [TypeError: homepageFooter.footerPress is not a function]

Output folder doesn't exist and cannot be created. TypeError: Cannot read property 'forEach' of undefined at /Users/pippo/Desktop/node_modules/nightwatch-cucumber/lib/cucumber-html-report.js:24:20 at Array.forEach (native) at /Users/pippo/Desktop/node_modules/nightwatch-cucumber/lib/cucumber-html-report.js:18:22 at Array.forEach (native) at setStats (/Users/pippo/Desktop/node_modules/nightwatch-cucumber/lib/cucumber-html-report.js:8:12) at generateReport (/Users/pippo/Desktop/node_modules/nightwatch-cucumber/lib/cucumber-html-report.js:102:11) at /Users/pippo/Desktop/node_modules/nightwatch-cucumber/lib/nightwatch-runner.js:182:9 at next (native) at onFulfilled (/Users/pippo/Desktop/node_modules/co/index.js:65:19)

mucsi96 commented 8 years ago

@Alfredo81 It was working on my machine. Please provide the result of the following command executed from the project root npm ls --depth 0

AlfredoMoretta commented 8 years ago

Igor this is the output of npm ls --depth 0 from the project root

iMac-3:NewRelease pippo$ npm ls --depth 0 nightwatch-cucumber@2.3.3 /Users/pippo/Desktop/NewRelease ├── chromedriver@2.21.2 ├── co@4.6.0 ├── glob@7.0.3 ├── lodash@4.13.1 ├── mkdirp@0.5.1 ├── object-assign@4.1.0 ├── phantomjs-prebuilt@2.1.7 ├── resolve@1.1.7 ├── selenium-server@2.53.0 ├── semver@5.1.0 ├── syntax-error@1.1.6 └── tmp@0.0.28

AlfredoMoretta commented 8 years ago

after the update at nightwatch-cucumber 3.0.0 the problem persist but the error is only this: [TypeError: homepageFooter.footerAboutClick is not a function] [TypeError: homepageFooter.footerPress is not a function] No assertions ran.

1 scenario (1 passed) 0 steps 0m00.000s

and the npm ls --depth 0 output is : nightwatch-cucumber@3.0.0 /Users/pippo/Desktop/NewRelease ├── chromedriver@2.21.2 ├── co@4.6.0 ├── cucumber@0.10.4 ├── glob@7.0.3 ├── lodash@4.13.1 ├── mkdirp@0.5.1 ├── nightwatch@0.9.1 ├── object-assign@4.1.0 ├── phantomjs-prebuilt@2.1.7 ├── pre-commit@1.1.3 ├── resolve@1.1.7 ├── selenium-server@2.53.0 ├── semver@5.1.0 ├── snazzy@4.0.0 ├── standard@7.1.1 ├── syntax-error@1.1.6 └── tmp@0.0.28

mucsi96 commented 8 years ago

According to the output you cloned the nightwatch-cucumber project to NewRelease folder This is not how it should be used. Please read the installation section of the readme: https://github.com/mucsi96/nightwatch-cucumber#installation

AlfredoMoretta commented 8 years ago

sorry igor my fault (i've tried some experiment with the hope that's work cloning the nightwatch cucumber to new release as you correctly said).My first npm ls --depth 0 (i've followed your readme at the start) is : /Users/pippo/NewRelease ├── chromedriver@2.21.2 ├── cucumber@1.0.0 ├── nightwatch@0.9.1 ├── nightwatch-cucumber@3.0.0 ├── phantomjs-prebuilt@2.1.7 └── selenium-server@2.53.0

and the error persist with this output: TypeError: homepageFooter.footerAboutClick is not a function at Object. (/Users/pippo/NewRelease/features/step_definitions/steps.js:4:24) at Object.run (/usr/local/lib/node_modules/cucumber/lib/cucumber/util/run.js:30:19) at Object.invoke (/usr/local/lib/node_modules/cucumber/lib/cucumber/support_code/step_definition.js:100:21) at Object.execute (/Users/pippo/NewRelease/node_modules/nightwatch-cucumber/lib/nightwatch-runner.js:230:29) at /Users/pippo/NewRelease/node_modules/nightwatch-cucumber/lib/nightwatch-runner.js:301:12 at Array.forEach (native) at Object.feature.discovered.(anonymous function) as First try prova at Module.call (/usr/local/lib/node_modules/nightwatch/lib/runner/module.js:62:34) at /usr/local/lib/node_modules/nightwatch/lib/runner/testcase.js:70:29 at _fulfilled (/usr/local/lib/node_modules/nightwatch/node_modules/q/q.js:834:54) TypeError: homepageFooter.footerPress is not a function at Object. (/Users/pippo/NewRelease/features/step_definitions/steps.js:12:24) at Object.run (/usr/local/lib/node_modules/cucumber/lib/cucumber/util/run.js:30:19) at Object.invoke (/usr/local/lib/node_modules/cucumber/lib/cucumber/support_code/step_definition.js:100:21) at Object.execute (/Users/pippo/NewRelease/node_modules/nightwatch-cucumber/lib/nightwatch-runner.js:230:29) at /Users/pippo/NewRelease/node_modules/nightwatch-cucumber/lib/nightwatch-runner.js:301:12 at Array.forEach (native) at Object.feature.discovered.(anonymous function) as First try prova at Module.call (/usr/local/lib/node_modules/nightwatch/lib/runner/module.js:62:34) at /usr/local/lib/node_modules/nightwatch/lib/runner/testcase.js:70:29 at _fulfilled (/usr/local/lib/node_modules/nightwatch/node_modules/q/q.js:834:54)

Thanks for helping mate

mucsi96 commented 8 years ago

Please checkout a newly created working test project: https://github.com/mucsi96/nw-cu-test

AlfredoMoretta commented 8 years ago

ok i found the error and was my fault(the new project is very useful for find the error).Thanks a lot for your support igor!i appreciate it and you're great ;)

mucsi96 commented 8 years ago

cool! no problem :) I am closing this issue.