问题描述
我正在http://the-internet.herokuapp.com/网站上使用C#和NUnit开发自动化测试项目。
在测试页面http://the-internet.herokuapp.com/basic_auth上是否存在以下警报时,Web驱动程序尽管存在警报,但仍无法在页面上检测到警报。它一直在提供NoAlertPresentException。
我正在使用下面给出的代码来检测警报
Internal WebDriver wait = new WebDriverWait(driver,TimeSpan.FromSeconds(10));
internal void WaitUntilAlertIsVisible()
{
try
{
wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.AlertIsPresent());
}
catch(WebDriverTimeoutException)
{}
}
internal bool IsAlertPresent()
{
try
{
WaitUntilAlertIsVisible();
driver.SwitchTo().Alert();
return true;
}
catch(NoAlertPresentException)
{
return false;
}
}
请帮助!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)