WebDriver 的 C 擴充套件
public static IWebDriver dismissAlert(this IWebDriver driver)
{
try
{
IAlert alert = driver.SwitchTo().Alert();
alert.Dismiss();
}
catch {}
return driver;
}
public static IWebDriver acceptAlert(this IWebDriver driver)
{
try
{
IAlert alert = driver.SwitchTo().Alert();
alert.Accept();
}
catch { }
return driver;
}
如何使用:
driver.acceptAlert();
driver.dismissAlert();