/// <summary> /// Logins the user. /// </summary> /// <param name="driver">The <paramref name="driver"/> instance.</param> /// <param name="userName">Name of the user.</param> /// <param name="userPassword">The user password.</param> /// <returns>If User login was successfully or not</returns> public static bool LoginUser(this ChromeDriver driver, string userName, string userPassword) { // Login User driver.Navigate().GoToUrl($"{TestConfig.TestForumUrl}{TestConfig.ForumUrlRewritingPrefix}login.aspx"); // Check If User is already Logged In if (!driver.PageSource.Contains("Forum Login")) { driver.FindElement(By.XPath("//a[contains(@id,'_LogOutButton')]")).ClickAndWait(); driver.FindElement(By.Id("forum_ctl02_OkButton")).Click(); driver.Navigate().GoToUrl($"{TestConfig.TestForumUrl}{TestConfig.ForumUrlRewritingPrefix}login.aspx"); } driver.FindElement(By.XPath("//input[contains(@id,'Login1_UserName')]")).SendKeys(userName); driver.FindElement(By.XPath("//input[contains(@id,'Login1_Password')]")).SendKeys(userPassword); driver.FindElement(By.XPath("//input[contains(@id,'Login1_LoginButton')]")).ClickAndWait(); driver.Navigate().GoToUrl(TestConfig.TestForumUrl); return(driver.ElementExists(By.XPath("//a[contains(@id,'LogOutButton')]"))); }