//Finding Edit Button //private IWebElement EditButton => GlobalDefinitions.driver.FindElement(By.XPath()) internal void EditListings() { //Populate the Excel Sheet GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ManageListings"); By WaitCond1 = By.XPath("//a[@href='/Home/ListingManagement']"); GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, WaitCond1, 60); ManageListingsTab.Click(); By WaitCondition = By.XPath("//th[text()='Image']"); GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, WaitCondition, 60); string Editrecord = GlobalDefinitions.ExcelLib.ReadData(2, "EditTitle"); GlobalDefinitions.driver.FindElement(By.XPath("//td[contains(text(),'" + Editrecord + "')]//following-sibling::td//child::i[@class='outline write icon']")).Click(); By WaitCond = By.XPath("//input[@name='title']"); GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, WaitCond, 60); ShareSkill EditSkillInstance = new ShareSkill(); EditSkillInstance.EnterShareSkill(); }
internal void EditShareSkill(string CategoryToSearch, string TitleToSearch, string DescriptionToSearch) { GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, By.LinkText("Manage Listings"), 10); //Navigate to Manage Listing page manageListingsLink.Click(); int RecordFound = 0; GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, By.XPath("//div[@id='listing-management-section']/div/div[1]/div[1]"), 5); Thread.Sleep(2000); // Searching for the added share skill record in the Manage Listing and validating is it available or not for (int i = 0; i < paginationButtons.Count - 2; i++) { Thread.Sleep(2000); //Loop for searching the added share skill through the pages foreach (IWebElement listingRecord in tableRows) { string Category = listingRecord.FindElement(By.XPath("td[2]")).Text; string Title = listingRecord.FindElement(By.XPath("td[3]")).Text; string Description = listingRecord.FindElement(By.XPath("td[4]")).Text; //Comparing Category,title,description to find out corresponding Edit button and Editing item if (Category == CategoryToSearch && Title == TitleToSearch && Description == DescriptionToSearch) { //Deleting a matched record int rowToBeEdited = tableRows.IndexOf(listingRecord) + 1; listingRecord.FindElement(By.XPath("//tr[" + rowToBeEdited + "]/td[8]/div/button[2]/i")).Click(); //log after editing Base.test.Log(LogStatus.Pass, "Share skill with titlename" + " " + Title + " " + "edit button is clicked and navigated to Edit share skill page"); RecordFound++; GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPathAddShareSkill, "EditShareSkill"); //Calling EnterShareSkill() for adding share skill data ShareSkill shareSkill = new ShareSkill(); shareSkill.EnterShareSkill(); //Validating edited record int MatchingRecordFoundAfterAdding = SearchListings(GlobalDefinitions.ExcelLib.ReadData(2, "Category"), GlobalDefinitions.ExcelLib.ReadData(2, "Title"), GlobalDefinitions.ExcelLib.ReadData(2, "Description")); int ExpectedRecords = MatchingRecordFoundAfterAdding + 1; try { if (MatchingRecordFoundAfterAdding > 0) { Base.test.Log(LogStatus.Pass, "Edited and saved a Share Skill Successfully"); Assert.IsTrue(true); } else { Base.test.Log(LogStatus.Fail, "Edit and adding a Share Skill is unsuccessful" + " " + "Screenshot Image " + GlobalDefinitions.SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "ShareSkillScreenshot")); } } catch (Exception e) { Base.test.Log(LogStatus.Fail, "Edit and adding a Share Skill is unsuccessful", e.Message); } return; } } if (nextButton.Enabled == true) { nextButton.Click(); } } }