//[TestCaseSource(typeof(SSLoginTestData), "TestCases")] public void DeleteUser() { try { LoginPageFlow loginPage = new LoginPageFlow().NavigateToLogin(); ThreadWait.WaitUntilElementAppears(LoginPage.UserNameElement()); HomePageFlow homePage = loginPage.LoginAsSucess("admin", "admin@123"); ThreadWait.WaitUntilElementAppears(HomePage.LogoutElement()); Assert.IsTrue(Driver.PageSource.Contains("Welcome admin"), "Failed User Login" + "userName"); homePage.SelectAdminMenu(); homePage.SelectUserDashboardMenu(); UserDashboardPageFlow userdashboard = new UserDashboardPageFlow(); ThreadWait.WaitUntilElementAppears(UserDashboardPage.GridTable()); userdashboard.DeleteUser("john123"); Thread.Sleep(3000); Driver.SwitchTo().Alert().Accept(); Thread.Sleep(3000); ThreadWait.WaitUntilElementAppears(HomePage.LogoutElement()); homePage.UserLogout(); LogEvent("User dashbaord - Delete user_Successful() - Passed"); } catch (Exception e) { new ScreenShotImage().CaptureScreenShot("DashboardDeleteUser"); LogEvent("Userdashboard -Delete User Failed\n\r" + e.Message + Environment.NewLine + e.StackTrace, EventTypes.Error); throw; } }
public void DeleteUser(string userName) { IWebElement table_element = Driver.FindElement(By.XPath(UserDashboardPage.GridTable())); ReadOnlyCollection <IWebElement> tr_collection = table_element.FindElements(By.XPath(UserDashboardPage.GridTableRow())); for (int i = 2; i < tr_collection.Count; i++) { if (Driver.FindElement(By.XPath(UserDashboardPage.UserNameColumofRow(i))).Text.Contains(userName)) { Driver.FindElement(By.XPath(UserDashboardPage.DeleteButtonColumofRow(i))).Click(); } } }