Firefox alert box not detected with Selenium WebDriver

后端 未结 2 1547
一生所求
一生所求 2021-01-28 14:07

ERROR net.serenitybdd.core.Serenity - No alert is present (WARNING: The server did not provide any stacktrace information)

I get this erro

2条回答
  •  生来不讨喜
    2021-01-28 14:10

    You might need to add code to wait for the alert to be visible. Selenium can't tell if JavaScript has finished executing.

    waitForAlert(WebDriver driver)
    {
       int i=0;
       while(i++<5)
       {
            try
            {
                Alert alert = driver.switchTo().alert();
                break;
            }
            catch(NoAlertPresentException e)
            {
              Thread.sleep(1000);
              continue;
            }
       }
    }
    

提交回复
热议问题