I have a selenium Webdriver script that has if else loops. When I execute the script, the code always stops at the first if condition and does not move to the else part at all. And then i get an Exception as the if condition is false. Is there any way out to work around the looping part in selenium web driver? I am using C# for coding. Thanks in Advance.
Following is the looping structure i have used in my script:
if (driver.FindElement(By.Id("ctl00_ContentMain_Label_Error")).Text.Contains("The username is already registered with Current Brand"))
{
//take a screen shot
}
else if (driver.FindElement(By.Id("ctl00_Label_WelcomeMessage")).Text == "You are not currently signed in")
{
//take a screen shot
}
else if (driver.FindElement(By.Id("ctl00_ContentLeftNav_UserNavBar_MenuItemLogOut")).Text == "Log Out")
{
//take a screenshot
}