public bool NavigateToEditDetails() { bool ServiceMatchFound = false; Wait.wait(2, driver); try { //Get the list of rows in the table for the last Page IList <IWebElement> ListingRows = ManageListingsTable.FindElements(By.TagName("tr")); if (ListingRows.Count == 2) { if (driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/div[1]/table/tbody/tr[position()=1]/td[3]")).Text == TitleEdit) { ServiceMatchFound = true; EditDetailsIcon.Click(); } else { TestContext.WriteLine("The service to be edited is not present in the Manage listings"); } } else { //Check for the services to be edited based on the title for (int entry = 1; entry < ListingRows.Count; entry++) { if (driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/div[1]/table/tbody/tr[position()=" + entry + "]/td[3]")).Text == TitleEdit) { driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/div[1]/table/tbody/tr[position()=" + entry + "]/td[8]/div/button[2]/i")).Click(); Thread.Sleep(500); ServiceMatchFound = true; break; } } //If the services to be edited is not present in the listings if (ServiceMatchFound == false) { TestContext.WriteLine("The service to be edited is not present in the Manage listings"); } } }catch (Exception e) { TestContext.WriteLine("There are no services listed in the page", e.Message); } return(ServiceMatchFound); }
public void DeleteDetails() { bool ServiceMatchFound = false; try { //Get the list of rows in the table for the last Page IList <IWebElement> ListingRows = ManageListingsTable.FindElements(By.TagName("tr")); //If there is a single service listed if (ListingRows.Count == 2) { if (driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/div[1]/table/tbody/tr[position()=1]/td[3]")).Text == TitleDelete) { ServiceMatchFound = true; DeleteDetailsIcon.Click(); } else { TestContext.WriteLine("The service to be deleted is not present in the Manage listings"); } } //If there are more than a service listed else { //Check for the services to be edited based on the title for (int entry = 1; entry < ListingRows.Count; entry++) { if (driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/div[1]/table/tbody/tr[position()=" + entry + "]/td[3]")).Text == TitleDelete) { driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/div[1]/table/tbody/tr[position()=" + entry + "]/td[8]/div/button[3]/i")).Click(); Thread.Sleep(500); ServiceMatchFound = true; break; } } //If the services to be deleted is not present in the listings if (ServiceMatchFound == false) { TestContext.WriteLine("The service to be deleted is not present in the Manage listings"); } } } catch (Exception e) { TestContext.WriteLine("There are no services listed in the page", e.Message); } //Proceed to delete only if the match is found if (ServiceMatchFound == true) { //Wait for Delete your service Text Box to be visible Wait.ElementIsVisible(driver, "XPath", "/html/body/div[2]/div/div[3]/button[2]"); //Click on 'Yes' button Yes.Click(); //Wait for Delete your service Text Box to be visible Wait.ElementIsVisible(driver, "XPath", "//div[@class='ns-box-inner']"); //Get the text from the pop up String msg = driver.FindElement(By.XPath("//div[@class='ns-box-inner']")).Text; String DeletePopUpMsg = $"{TitleDelete} has been deleted"; //Check for the Pop message for delete Assert.That(msg, Is.EqualTo(DeletePopUpMsg)); } }