I am trying to close the window but it is giving me javascript alert to click either "Leave" or "Stay".
I tried $browser.execute_script("window.confirm = function() {return true}") code, but it's not working.
execute this code:
window.onbeforeunload = null;