Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wait until alert is not present - Selenium/Python

I found this answer https://stackoverflow.com/a/19019311/1998220 that waits until the alert is present, but I need the opposite so whoever runs the macro has time to authenticate on the proxy pop up. Is there an opposite to the below code?

WebDriverWait(browser, 60).until(EC.alert_is_present())
like image 790
Michael St Clair Avatar asked Jan 14 '16 17:01

Michael St Clair


1 Answers

You can wait for a specific URL, title, or a specific element to be present or visible, but you can also have a specific alert_is_not_present custom Expected Condition:

class alert_is_not_present(object):
    """ Expect an alert to not to be present."""
    def __call__(self, driver):
        try:
            alert = driver.switch_to.alert
            alert.text
            return False
        except NoAlertPresentException:
            return True
like image 171
alecxe Avatar answered Sep 20 '22 11:09

alecxe