public void DisableUser(string emailaddress, log4net.ILog log) { //instantiate new Adduserdetailspage LAFAdmin_ManageUsers_Page usersPage = new LAFAdmin_ManageUsers_Page(driver); USERS_link.Click(); Email_Address_Text.SendKeys(emailaddress); Search_link.Click(); SEARCH_RESULTS_links.Click(); try { Disable_user_account_link.Click(); driver.SwitchTo().ActiveElement().SendKeys("test"); driver.SwitchTo().ActiveElement().SendKeys(Keys.Return); } catch (NoSuchElementException ex) { //If failed, this is most likely because the user is disabled Assert.IsTrue(isElementPresent(Enable_user_account_link)); //If so continue test log.Info("User already disabled. Continue Test"); } Assert.IsTrue(isElementPresent(Enable_user_account_link)); try { USERS_link.Click(); } catch { PageFactory.InitElements(driver, this); USERS_link.Click(); } usersPage = null; log.Info("User '" + emailaddress + "' disabled successfully."); /** * try * { * Assert.IsFalse(isElementPresent((SEARCH_RESULTS_links))); * * } * catch * { * * Thread.Sleep(1000); * usersPage = new LAFAdminManageusersPage(driver); * Assert.IsFalse(isElementPresent((SEARCH_RESULTS_links))); * * } * **/ }
public void DeleteUser(string emailaddress, log4net.ILog log) { //instantiate new Adduserdetailspage PageFactory.InitElements(driver, this); USERS_link.Click(); Email_Address_Text.SendKeys(emailaddress); Search_link.Click(); SEARCH_RESULTS_links.Click(); Delete_user_account_link.Click(); I_wish_to_delete_this_user_from_laf_checkbox.Click(); Confirm_Deletion_Of_User_link.Click(); try { Email_Address_Text.SendKeys(emailaddress); } catch { PageFactory.InitElements(driver, this); Email_Address_Text.SendKeys(emailaddress); } Search_link.Click(); Assert.IsFalse(isElementPresent((SEARCH_RESULTS_links))); USERS_link.Click(); log.Info("User '" + emailaddress + "' deleted successfully."); /** * try * { * Assert.IsFalse(isElementPresent((SEARCH_RESULTS_links))); * * } * catch * { * * Thread.Sleep(1000); * usersPage = new LAFAdminManageusersPage(driver); * Assert.IsFalse(isElementPresent((SEARCH_RESULTS_links))); * * } * **/ }
//Methods: public void CreateNewUser(string emailaddress, string firstName, log4net.ILog log) { //Create an instance of the LAFAdmin_ManageUsers_Page //I will just call this instance 'usersPage' for short: log.Info("Test Start: CreateNewUser, username="******"Mr"); First_Name_text.SendKeys(firstName); Last_Name_text.SendKeys("Test"); Country_of_Residence_dropdown.SendKeys("United Kingdom"); Contact_Telephone_Number_text.SendKeys("123"); Are_you_an_insurance_professional_dropdown.SendKeys("No"); Job_title_text.SendKeys("Tester"); Company_name_text.SendKeys("Testing LTD"); Organisation_type_dropdown.SendKeys("Lloyds corporation"); Save_link.Click(); //Assertion: Email_Address_Text.SendKeys(emailaddress); Search_link.Click(); Assert.IsTrue(SEARCH_RESULTS_links.Displayed); log.Info("New User Created Successfully"); try { USERS_link.Click(); } catch { PageFactory.InitElements(driver, this); USERS_link.Click(); } }
public void SearchByEmail(string emailaddress, log4net.ILog log) { Email_Address_Text.SendKeys(emailaddress); Search_link.Click(); }
public void EnableUser(string emailaddress, log4net.ILog log, IWebDriver driver) { //instantiate new Adduserdetailspage try { USERS_link.Click(); Email_Address_Text.SendKeys(emailaddress); } catch (Exception ex) { PageFactory.InitElements(driver, this); log.Info("Staleblock" + ex.ToString()); USERS_link.Click(); Email_Address_Text.SendKeys(emailaddress); } Search_link.Click(); try { SEARCH_RESULTS_links.Click(); } catch (Exception) { PageFactory.InitElements(driver, this); SEARCH_RESULTS_links.Click(); } Enable_user_account_link.Click(); driver.SwitchTo().ActiveElement().SendKeys("test"); driver.SwitchTo().ActiveElement().SendKeys(Keys.Return); Assert.IsTrue(isElementPresent(Disable_user_account_link)); //Now check if reset password link is available - if it is click this too, to ensure that user is actually enabled //May move this to another test eventually try { USERS_link.Click(); } catch (Exception) { PageFactory.InitElements(driver, this); USERS_link.Click(); } log.Info("User '" + emailaddress + "' deleted successfully."); /** * try * { * Assert.IsFalse(isElementPresent((SEARCH_RESULTS_links))); * * } * catch * { * * Thread.Sleep(1000); * usersPage = new LAFAdminManageusersPage(driver); * Assert.IsFalse(isElementPresent((SEARCH_RESULTS_links))); * * } * **/ }
public void ResetPasswordAttempts(string emailaddress, log4net.ILog log) { //instantiate new Adduserdetailspage USERS_link.Click(); try { Email_Address_Text.SendKeys(emailaddress); } catch (StaleElementReferenceException ex) { log.Info("Staleblock" + ex.ToString()); PageFactory.InitElements(driver, this); Email_Address_Text.SendKeys(emailaddress); } Search_link.Click(); try { SEARCH_RESULTS_links.Click(); } catch (Exception) { PageFactory.InitElements(driver, this); SEARCH_RESULTS_links.Click(); } //Check that it is visible (i.e. USer needs to have attempts reset) Assert.IsTrue(isElementPresent(Reset_password_attempts_link)); Reset_password_attempts_link.Click(); driver.SwitchTo().ActiveElement().SendKeys("test"); driver.SwitchTo().ActiveElement().SendKeys(Keys.Return); //Ensure that it has been clicked Assert.IsFalse(isElementPresent(Reset_password_attempts_link)); try { USERS_link.Click(); } catch (Exception) { PageFactory.InitElements(driver, this); USERS_link.Click(); } log.Info("User '" + emailaddress + "' password reset successfully."); /** * try * { * Assert.IsFalse(isElementPresent((SEARCH_RESULTS_links))); * * } * catch * { * * Thread.Sleep(1000); * usersPage = new LAFAdminManageusersPage(driver); * Assert.IsFalse(isElementPresent((SEARCH_RESULTS_links))); * * } * **/ }