// Pass in null if want to run your test-case without logging in. public static void ClassInitialize(Login login = null) { _testClassesRunning++; if (login == null) { Logoff(); } else if (!IsCurrentlyLoggedInAs(login)) { Logon(login); } }
private static void Logon(Login login) { StaticDriver.Navigate().GoToUrl(BaseUrl + VirtualPath + "/Logon.aspx"); StaticDriver.FindElement(By.Id("userId")).SendKeys(login.Username); StaticDriver.FindElement(By.Id("password")).SendKeys(login.Password); StaticDriver.FindElement(By.Id("btnLogin")).Click(); _currentlyLoggedInAs = login; }
private static void Logoff() { StaticDriver.Navigate().GoToUrl(VirtualPath + "/Logoff.aspx"); _currentlyLoggedInAs = null; }
private static bool IsCurrentlyLoggedInAs(Login login) { return _currentlyLoggedInAs != null && _currentlyLoggedInAs.Equals(login); }