Nightwatch: Error on assertion fail

Created on 15 May 2016  Â·  4Comments  Â·  Source: nightwatchjs/nightwatch

I've upgraded my nightwatch to the latest version (0.8.18) and now I'm getting an error every time an assertion fails.
The problem is with Q promise library but I don't know how to solve this.
I've also tried to pull the specific Q version (1.1.2) listed in the package.json file of nightwatch but I keep getting the same error.

I'm using node v0.12.2 on mac os x El Capitan 10.11.4 and on Windows 2008 server
This is my test file -
module.exports = { 'Demo test Google' : function (client) { client .url('http://www.google.com') .waitForElementVisible('body', 1000) .assert.title('Google') .assert.visible('input[type=text]') .setValue('input[type=text]', 'rembrandt van rijn') .waitForElementVisible('button[name=btnG]', 1000) .click('button[name=btnG]') .pause(1000) .assert.containsText('ol#rso li:first-child', 'Rembrandt - Wikipedia') .end(); } };

And this is the error I get -
Starting selenium server... started - PID: 24083

[Sample] Test Suite

Running: Demo test Google
✔ Element was visible after 58 milliseconds.
✔ Testing if the page title equals "Google".
✔ Testing if element ✖ Timed out while waiting for element at Object.module.exports.Demo test Google (/Users/shaharzrihen/Development/Namogoo/nightwatch/sample.js:9:8)
at Module.call (/Users/shaharzrihen/Development/Namogoo/nightwatch/lib/runner/module.js:63:34)
at /Users/shaharzrihen/Development/Namogoo/nightwatch/lib/runner/testcase.js:97:29
at _fulfilled (/Users/shaharzrihen/Development/Namogoo/nightwatch/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/Users/shaharzrihen/Development/Namogoo/nightwatch/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/Users/shaharzrihen/Development/Namogoo/nightwatch/node_modules/q/q.js:796:13)
at /Users/shaharzrihen/Development/Namogoo/nightwatch/node_modules/q/q.js:556:49
at runSingle (/Users/shaharzrihen/Development/Namogoo/nightwatch/node_modules/q/q.js:137:13)
at flush (/Users/shaharzrihen/Development/Namogoo/nightwatch/node_modules/q/q.js:125:13)
at process._tickCallback (node.js:355:11)

FAILED: 1 assertions failed and 3 passed (5.03s)


TEST FAILURE: 1 assertions failed, 3 passed (5.127s)
✖ sample

  • Demo test Google
    Timed out while waiting for element

This happens on FF and Chrome.

Any tips on how to resolve this?

Most helpful comment

On Google, the name of the button is now called btnK instead of btnG and the type is changed from 'button' to 'input.' The test should be: .waitForElementVisible('input[name=btnK]', 1000)

All 4 comments

It looks like the test fails. What is the error?

The assertion should fail. My problem is that the q.js library is throwing an error every time an assertion fails. I didn't have that issue on earlier versions of nightwatch and I'm worried it might effect more complex tests and it's creating an issue with the log parser.

That's not an error, it's just the stack trace for the failure. In previous versions the stacktrace wasn't printed at all. Nightwatch uses q.js internally so that's why you are seeing it in the stacktrace, it doesn't mean there's an error. In the next vesion, the irrelevant lines from the stacktrace will be removed to avoid clutter and confusion. Sorry for the inconvenience, but you can safely ignore those lines for now.

On Google, the name of the button is now called btnK instead of btnG and the type is changed from 'button' to 'input.' The test should be: .waitForElementVisible('input[name=btnK]', 1000)

Was this page helpful?
0 / 5 - 0 ratings