0
votes

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 ?????

1

1 Answers

1
votes

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; 
    }
}