internal void DeleteShareSkill() { try { //Click on Manage Listings ManageListings.Click(); GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ManageListingExcelPath, "ManageListings"); string FirstPath = "//*[@id='listing-management-section']/div[2]/div[1]/div[1]/table/tbody/tr["; string SecondPath = "]/td[3]"; string getTitle = null; bool flag = false; int temp = 0; while (true) { for (int rownum = 1; rownum <= (Totalrows.Count); rownum++) { getTitle = GlobalDefinitions.driver.FindElement(By.XPath(FirstPath + rownum + SecondPath)).Text; temp = 1; if (getTitle == GlobalDefinitions.ExcelLib.ReadData(2, "Title")) { if (GlobalDefinitions.ExcelLib.ReadData(2, "Deleteaction") == "Yes") { //Click on Delete GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/div[1]/table/tbody/tr[" + rownum + "]/td[8]/div/button[3]/i")).Click(); GlobalDefinitions.wait(10000); Yes.Click(); GlobalDefinitions.wait(10000); Assert.Pass("Record is successfully deleted"); flag = true; return; } else { //Click on Delete GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/div[1]/table/tbody/tr[" + rownum + "]/td[8]/div/button[3]/i")).Click(); GlobalDefinitions.wait(10000); No.Click(); GlobalDefinitions.wait(10000); Assert.Pass("There is matching record but it is not deleted"); flag = true; return; } } } if (flag == false) { NextPage.Click(); } if (temp == 1) { Assert.Pass("There is no matching record to delete"); } } } catch (Exception ex) { Console.WriteLine(ex.Message);; } }
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)); } }
public void DeleteManageListing() { //Click on Managelisting Link manageListingsLink.Click(); GlobalDefinitions.wait(30); String DelStatus = "False"; int i; //Itertaing Through The table try { while (DelStatus == "False") { for (i = 1; i <= 5; i++) { //Get the Text of CATEGORY var CtgryTxt = GlobalDefinitions.driver.FindElement(By.XPath("/html/body/div/div/div/div[2]/div[1]/div[1]/table/tbody/tr[" + i + "]/td[2]")).Text; //Get the Text of TITLE var TitleTxt = GlobalDefinitions.driver.FindElement(By.XPath("/html/body/div/div/div/div[2]/div[1]/div[1]/table/tbody/tr[" + i + "]/td[3]")).Text; //Get The Text of DESCRIPTION var DscrptnTxt = GlobalDefinitions.driver.FindElement(By.XPath("/html/body/div/div/div/div[2]/div[1]/div[1]/table/tbody/tr[" + i + "]/td[4]")).Text; //Get the Text of SERVICE TYPE var SrvcType = GlobalDefinitions.driver.FindElement(By.XPath("/html/body/div/div/div/div[2]/div[1]/div[1]/table/tbody/tr[" + i + "]/td[5]")).Text; //Assert.AreEqual(CtgryTxt, "Programming & Tech"); //Assert.AreEqual(TitleTxt, "Software Tester"); //Assert.AreEqual(DscrptnTxt, "Api , Selenium C Tester"); //Assert.AreEqual(SrvcType, "Hourly"); if (CtgryTxt == "Programming & Tech" && TitleTxt == "Software Tester" && DscrptnTxt == "Api , Selenium C Tester" && SrvcType == "Hourly") { //Identify Delete CROSS SIGN IWebElement Delete = GlobalDefinitions.driver.FindElement(By.XPath("/html/body/div/div/div/div[2]/div[1]/div[1]/table/tbody/tr[" + i + "]/td[8]/div/button[3]/i")); //Click On delete Delete.Click(); //Click on Yes Yes.Click(); DelStatus = "True"; break; } } if (DelStatus == "False") { i = 0; //Click on Next Page NextPage.Click(); } } } catch (Exception e) { Console.WriteLine(e.Message); } }