from selenium.common.exceptions import NoAlertPresentException
try:
    context.driver.switch_to.alert.accept()
except NoAlertPresentException:
    pass
how to handle javascript alerts in selenium using python