How wait for alert box to perform the action in Selenium?

前端 未结 1 1937
被撕碎了的回忆
被撕碎了的回忆 2021-01-18 06:36

I am pressing a cancel button than according to my code it is checking some text. In Chrome and Firefox it is working fine but in IE it is taking time to perform operation

相关标签:
1条回答
  • 2021-01-18 07:22

    You want to wait until the alert is present before switching to it, similar to your 3rd row. Reference.

    EDIT: try:

    new WebDriverWait(driver, 60)
            .ignoring(NoAlertPresentException.class)
            .until(ExpectedConditions.alertIsPresent());
    
    Alert al = driver.switchTo().alert();
    al.accept();
    
    0 讨论(0)
提交回复
热议问题