How to close a confirm dialog opened by another window in GEB

953 views Asked by At

In one of my functional GEB tests we have a situation where we are opening a new window by using

withNewWindow({ button.click() }, "close": true, "wait": true) {
   //Other things
}

Now when that window is being closed a confirm dialog is opening which says whether you want to leave this page or not. How to close that confirm dialog?

I know that there is a method withConfirm for closing confirm dialogs but I am not doing anything to open/close it but instead withNewWindow is opening/closing that.

I tried various options but couldn't figure out how to do that. I looked at the docs but couldn't find any examples for this.

1

There are 1 answers

2
erdi On BEST ANSWER

You will need to pass false for the close option of withNewWindow() and then wrap closing the newly opened window in a withConfirm() call in such case:

withNewWindow({ button.click() }, close: false, wait: true) {
    //Other things
    withConfirm { driver.close() }
}