I am writing tests for a web App using selenium webDriver and came across a scenario where when I try to close the browser I get a popup saying \"Are you sure? The page is a
Not sure what is the structure of the popup that you have used. Here are a few that may work for you if you have used either of as to popup.
If its an alert. you can try:
driver.SwitchTo().Alert()
If its a window that pops up then:
driver.SwitchTo().Window(<windowname>)
For iFrame:
driver.SwitchTo().Frame("iFrmLinks")
Once you get through either of the three then you can access all its internal elements.
Regards Tahir
( ( JavascriptExecutor ) _driver )
.executeScript( "window.onbeforeunload = function(e){};" );
solved the issue for me
def close_all_popups(driver):
driver.window_handles
for h in driver.window_handles[1:]:
driver.switch_to_window(h)
driver.close()
driver.switch_to_window(driver.window_handles[0])