//Add new certifiaction internal void AddNewCertification() { Extension.WaitForElementDisplayed(Driver, By.XPath("//h3[contains(text(),'Certification')]/../..//div[text()='Add New']"), 2); //Click Add New button AddNewCertificationButton.Click(); //Enter the Certification Details Extension.WaitForElementDisplayed(Driver, By.Name("certificationName"), 2); AddCertificationName.SendKeys(ExcelLib.ReadData(2, "CertificationName")); AddCertificationFrom.SendKeys(ExcelLib.ReadData(2, "CertificationFrom")); SelectDropDown(ChooseCertificationYear, "SelectByValue", ExcelLib.ReadData(2, "CertificationYear")); //Click Add button AddCertificationButton.Click(); Base.Image = SaveScreenShotClass.SaveScreenshot(Driver, "Report"); //Validate message Extension.MessageValidation(ExcelLib.ReadData(2, "CertificationName") + " has been added to your certification"); }
//Update the existing Certification internal void UpdateCertification() { //Get the Certification value needs to be updated String expectedValue = ExcelLib.ReadData(2, "CertificationName"); //Get the rows count in Certification table IList <IWebElement> Tablerows = Driver.FindElements(By.XPath("//h3[contains(text(),'Certification')]/../..//table/tbody/tr")); var rowCount = Tablerows.Count; //Get the actual Certification value and compare with Certification needs to be updated, if matches update the record for (int i = 1; i <= rowCount; i++) { String actualValue = Driver.FindElement(By.XPath("//h3[contains(text(),'Certification')]/../..//tbody[" + i + "]/tr/td[1]")).Text; if (expectedValue == actualValue) { //Click on Edit icon Driver.FindElement(By.XPath("//h3[contains(text(),'Certification')]/../..//tbody[" + i + "]/tr/td[4]/span[1]/i")).Click(); //Clear the existing value and add new value Extension.WaitForElementDisplayed(Driver, By.Name("certificationName"), 2); AddCertificationName.Clear(); AddCertificationName.SendKeys(ExcelLib.ReadData(2, "UpdateCertificationName")); AddCertificationFrom.Clear(); AddCertificationFrom.SendKeys(ExcelLib.ReadData(2, "UpdateCertificationFrom")); SelectDropDown(ChooseCertificationYear, "SelectByValue", ExcelLib.ReadData(2, "UpdateCertificationYear")); //Click update button UpdateCertificationButton.Click(); Base.Image = SaveScreenShotClass.SaveScreenshot(Driver, "Report"); //Validate message Extension.MessageValidation(ExcelLib.ReadData(2, "UpdateCertificationName") + " has been updated to your certification"); } } }