public void WhenIHaveLoggedIntoTheCourseSpaceAsCSStudent() { try { string browserName = WebDriver.Title.ToString(CultureInfo.InvariantCulture); if (browserName != "Global Home") { GenericHelper.SelectDefaultWindow(); WebDriver.Manage().Cookies.DeleteAllCookies(); string csUserUNDb = DatabaseTools.GetEnrolledUserLoginName(Enumerations.UserType.CsStudent); if (csUserUNDb == null) { throw new ArgumentNullException("csUserUNDb is NULL, Us" + "er not fullfilling his login criteria."); } string csUserPwdDb = DatabaseTools.GetEnrolledUserPassword(Enumerations.UserType.CsStudent); if (csUserPwdDb == null) { throw new ArgumentNullException("csUserPwdDb is NULL, Us" + "er not fullfilling his login criteria."); } if (GenericHelper.IsElementPresent(By.Id("_ctl6_PegasushelloK5_lblWelcomeText"))) { if (Browser.Equals("IE")) { if ( !WebDriver.FindElement(By.Id("_ctl6_PegasushelloK5_lblWelcomeText")).GetAttribute("innerText").Contains("Welcome " + csUserUNDb)) { WebDriver.Navigate().GoToUrl(DatabaseTools.GetUrl(Enumerations.UserType.CsTeacher)); LoginPage.Login(csUserUNDb, csUserPwdDb, "coursespace", "CSStudent"); Thread.Sleep(60000);//This I have added To Avoid HTTP Connection Break Due To Slow Loading } } if (Browser.Equals("FF") || Browser.Equals("GC")) { if ( !WebDriver.FindElement(By.Id("_ctl6_PegasushelloK5_lblWelcomeText")).Text.Contains("Welcome " + csUserUNDb)) { WebDriver.Navigate().GoToUrl(DatabaseTools.GetUrl(Enumerations.UserType.CsTeacher)); LoginPage.Login(csUserUNDb, csUserPwdDb, "coursespace", "CSStudent"); Thread.Sleep(60000);//This I have added To Avoid HTTP Connection Break Due To Slow Loading } } } else { WebDriver.Navigate().GoToUrl(DatabaseTools.GetUrl(Enumerations.UserType.CsTeacher)); LoginPage.Login(csUserUNDb, csUserPwdDb, "coursespace", "CSStudent"); Thread.Sleep(60000);//This I have added To Avoid HTTP Connection Break Due To Slow Loading } } } catch (Exception e) { GenericHelper.Logs(e.ToString(), "FAILED"); throw new Exception(e.ToString()); } }