Closed AlfredoMoretta closed 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
Because the page-obeject test associated with the build passed successfully
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 } }
@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: {}
}
@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)
@Alfredo81 It was working on my machine. Please provide the result of the following command executed from the project root npm ls --depth 0
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
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
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
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.
Thanks for helping mate
Please checkout a newly created working test project: https://github.com/mucsi96/nw-cu-test
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 ;)
cool! no problem :) I am closing this issue.
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:
is it possible that is a regression for the update?
thank you, Alfredo