public void RemoveAllServices() { Global.GlobalDefinitions.ExcelLib.PopulateInCollection(Global.Base.ExcelPath, "ListingManagement"); Global.GlobalDefinitions.wait(2000); ManageListing.Click(); Base.test.Log(LogStatus.Info, "Starting removing Service"); Global.GlobalDefinitions.wait(5000); try { foreach (IWebElement ele in Remove) { WebDriverWait wait = new WebDriverWait(Global.GlobalDefinitions.driver, TimeSpan.FromSeconds(10)); wait.Until(ExpectedConditions.ElementToBeClickable((ele))); ele.Click(); ModalYesButton.Click(); Global.GlobalDefinitions.wait(5000); } } catch (Exception e) { IWebElement NoListings = Global.GlobalDefinitions.driver.FindElement(By.XPath("//h3[contains(text(),'You do not have any service listings!')]")); if (NoListing.Displayed) { Global.Base.test.Log(LogStatus.Info, "There are no services to remove"); } else { Global.Base.test.Log(LogStatus.Info, "Something went wrong!" + e); } } }
public void RemoveServiceDetails() { Global.GlobalDefinitions.ExcelLib.PopulateInCollection(Global.Base.ExcelPath, "ListingManagement"); Global.GlobalDefinitions.wait(2000); ManageListing.Click(); Base.test.Log(LogStatus.Info, "Starting removing Service"); Global.GlobalDefinitions.wait(5000); bool RecordFound = false; int flag = 0; //try //{ // for (int p = 0; p < NoOfPages.Count; p++) // { // for (int i = 0; i < Title.Count; i++) // { // Console.WriteLine("i value:" + i); // if ((Global.GlobalDefinitions.ExcelLib.ReadData(2, "Title") == Title[i].Text) && (Global.GlobalDefinitions.ExcelLib.ReadData(2, "Category") == Category[i].Text)) // { // RecordFound = true; // WebDriverWait wait = new WebDriverWait(Global.GlobalDefinitions.driver, TimeSpan.FromSeconds(10)); // wait.Until(ExpectedConditions.ElementToBeClickable((Remove[i]))); // Remove[i].Click(); // Console.WriteLine("removing row:"+i); // Global.GlobalDefinitions.wait(2000); // ModalYesButton.Click(); // i = i - 1; // } // } // if (NextPage.Enabled) // NextPage.Click(); // else if (RecordFound == false) // { // Global.Base.test.Log(LogStatus.Info, "There are no matching listings!"); // } // } //} try { for (int p = 0; p < NoOfPages.Count; p++) { for (int i = 0; i < Title.Count; i++) { Global.GlobalDefinitions.wait(7000); if (flag == Title.Count) { break; } else if ((Global.GlobalDefinitions.ExcelLib.ReadData(2, "Title") == Title[i].Text) && (Global.GlobalDefinitions.ExcelLib.ReadData(2, "Category") == Category[i].Text)) { RecordFound = true; WebDriverWait wait = new WebDriverWait(Global.GlobalDefinitions.driver, TimeSpan.FromSeconds(10)); wait.Until(ExpectedConditions.ElementToBeClickable((Remove[i]))); Remove[i].Click(); ModalYesButton.Click(); Global.GlobalDefinitions.wait(2000); i = i - 1; flag++; } } if (NextPage.Enabled) { NextPage.Click(); } else if (RecordFound == false) { Global.Base.test.Log(LogStatus.Info, "There are no matching listings!"); } } } catch (Exception e) { IWebElement NoListings = Global.GlobalDefinitions.driver.FindElement(By.XPath("//h3[contains(text(),'You do not have any service listings!')]")); if (NoListing.Displayed) { Global.Base.test.Log(LogStatus.Info, "There are no services to remove"); } else { Global.Base.test.Log(LogStatus.Info, "Something went wrong!" + e); } } }