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.