Using Python 3 and Chromedriver.
Suppose an automated python program is surfing the web, fetching stuff from different sources.
Suppose any of those websites fires an "Are you sure you wanna leave this page?" alert.
Key word: any (in a random way) of those websites.
Question:
How may I set up the program to handle those alerts, by always saying: "yes, i want to leave this page".?
--- UPDATE ---
Possible approach:
Based on the comment below I am now doing:
def super_get(url):
driver.get(url)
driver.execute_script("window.onbeforeunload = function() {};")
And now use super_get() insetad of the standard driver.get()
Can you think of any more efficient or cleaner way of doing it?