from selenium import webdriver
# Create a new webdriver
driver = webdriver.Chrome()
# Get a page that has a popup window (Use mouse to click "try it" button)
driver.get("http://www.w3schools.com/js/tryit.asp?filename=tryjs_alert")
# Accept the opened alert
driver.switch_to.alert.accept()