Tuesday, 6 June 2017

nightwatch - check for popup window, after each click event

Is there a way in nightwatch to check whether a popup window appears after each click event?

I have a problem that randomly an error message appear and I don't want to write for each click event the same callback function.

I have already tried out the after and afterEach commands in the Global.js but then the commands will only run after the whole test suit. I also have tried it local within a test file, although it also does not cover all single click events, even thought the official website writes"... while beforeEach and afterEach are ran before and after each testcase (test step)"?

Solution I'm looking for:

.waitForElementVisible('selector')
    .click('selector')  
    .click('selector')  

Solution I have come up with so far:

.waitForElementVisible('selector')
    .click('selector', isPresent)  
    .click('selector', isPresent)  

isPresent as a callback function, which does the checking and close the popup window if it appears.

Is there another way to write a function (with or without after and/or forEach), so that it will be called after each click event or after each command. Thus, I don't have to write the isPresent repetitive code?

Thanks in advanced!



via Vitali Dettling

No comments:

Post a Comment