Reputation: 5
I am facing a issue while automating the script through selenium C#
I have a scenario in which a browser popup is displayed on the page after clicking a link.
I have to identify that on clicking the desired link whether the browser alert displayed or not.???
I need something like Is alert present ?????
Upvotes: 0
Views: 745
Reputation: 36
Simply try to accept the alert using try-catch: if alert accepted - step is passed, else - failed
if you need a method try the next (checking alert present):
public bool isAlertPresent()
{
try
{
driver.switchTo().alert();
return true;
}
catch (NoAlertPresentException Ex)
{
return false;
}
}
Upvotes: 1