How To Handle IE Setup Popup in Selenium

2019-08-20 02:58发布

问题:

how to handle IE set up in selenium click image for alert popup

回答1:

You can try to accept the alert via selenium. The following Java method should accept the alert and let you move on with your life.

public void checkAlert() 
{
    try 
    {
        // Wait for the alert to show
        WebDriverWait wait = new WebDriverWait(driver, 2);
        wait.until(ExpectedConditions.alertIsPresent());

        driver.switchTo().alert().accept();

    } 
    catch (Exception e) 
    {
        //exception handling
    }
}

You'll want to add import org.openqa.selenium.Alert; to your imports too.