nightwatchjs / nightwatch

Integrated end-to-end testing framework written in Node.js and using W3C Webdriver API. Developed at @browserstack
https://nightwatchjs.org
MIT License
11.79k stars 1.31k forks source link

weird behaviour after `click` #578

Closed sirLisko closed 9 years ago

sirLisko commented 9 years ago

I've got the following test:

'follow on twitter': function(browser){
    browser
        .url('http://www.nightwatchjs.org')
        .waitForElementVisible('body', 3000, 'page loaded')
        .waitForElementPresent('#twitter-widget-0', 3000)
        .click('#twitter-widget-0')

        .windowHandles(function(result) {
            browser.assert.equal(result.value.length, 2, 'there is a second window.');
            var handle = result.value[1];
            browser.switchWindow(handle);
        })

        .assert.urlContains('twitter')
        .closeWindow()
        .end();
}

It used to work fine literally for months, but lately it started failing and I don't have any idea about why.

I'm using the last version of nightwatch 0.7.9, selenium 2.46.0 and chromedriver 2.16.0. I've also tried to rollback my code to when it used to work but it still failing. My only, and I hope temporary, solution was to add a timeout but I really don't want to add a browser.pause(1000) after every click.

Any idea? Thanks!

sknopf commented 9 years ago

What exactly is the issue you're seeing (ie, is it not clicking or something else)? And can try running with --verbose to see if that sheds an light?

sirLisko commented 9 years ago

Ah yes, sorry, it's not clear. Basically in the windowHandles I get only one window.

✖ Assertion failed: there is a second window. - expected "2" but got: 1

beatfactor commented 9 years ago

Closing this due to lack of activity and details. Feel free to re-open if you have more data/steps to reproduce.

sirLisko commented 9 years ago

I pushed here https://github.com/sirLisko/nightwatch-ready a simple working version (with pause) and I've created a branch https://github.com/sirLisko/nightwatch-ready/tree/no-pause (without pause) in which the test fails.

The problem is that I don't think that is ideal add a pause after every click, personally I don't find it a cleaned and optimized way.

Let me know if it is still not clear enough.

sknopf commented 9 years ago

@sirLisko thanks for the steps to reproduce. I see the failure with no pause but this doesn't look like a nightwatch issue (the click request is getting fired, etc) - it just takes a moment for the window to open. I guess you could write a custom command to wait on 2 windows rather than calling pause as an improvement, but not seeing any actual issues in the nightwatch framework..

sirLisko commented 9 years ago

The thing is that the problem occurs also if I click an element that triggers a javascript event. Adding a pause in this case seems to me a bit overkill, but in the other hand I'm not sure what should be the best practise in this case.

danielstocks commented 8 years ago

@sirLisko If you came up with a clean solution for this (avoiding pause) I'm also interested.

sirLisko commented 8 years ago

Unfortunately I didn't find any ideal solution. At the moment I've a waitFor that checks every second if the second window is there, but it's pretty bad :(

@danielstocks please give me a shout if you find out something better.