//Edit Method public void EditListing(IWebDriver Driver) { //Populate the Excel sheet Global.GlobalDefinitions.ExcelLib.PopulateInCollection(Global.Base.ExcelPath, "EditShareSkillTestData"); //Click Manage Listings Menu ManageListingsMenu.Click(); Thread.Sleep(7000); //Click Edit Icon IJavaScriptExecutor js1 = (IJavaScriptExecutor)Driver; js1.ExecuteScript("arguments[0].click();", Element); Thread.Sleep(5000); //Change Title string title1 = Title.Text; Title.Clear(); Title.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Title")); //Click Savebutton SaveBtn.Click(); Thread.Sleep(5000); //Verification ManageListingsMenu.Click(); Thread.Sleep(7000); //Click Edit icon IJavaScriptExecutor js2 = (IJavaScriptExecutor)Driver; js2.ExecuteScript("arguments[0].click();", Element); Thread.Sleep(5000); try { Assert.AreEqual("Industry Connect Software Tester", Title.Text); Console.WriteLine("Test1 passed : title edited successfully"); //Screenshot String img = Global.GlobalDefinitions.SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.Driver, "Report"); Base.test.Log(LogStatus.Info, "Image example: " + img); //end test. (Reports) Base.extent.EndTest(Base.test); //calling Flush writes everything to the log file(Reports) Base.extent.Flush(); } catch (Exception e) { Console.WriteLine(e); Console.WriteLine("Test Fail: Skill listing NOT Edited"); } }
public void DeleteListing(IWebDriver Driver) { //Click Manage Listings Menu ManageListingsMenu.Click(); Thread.Sleep(5000); IJavaScriptExecutor javascript = (IJavaScriptExecutor)Driver; javascript.ExecuteScript("arguments[0].click();", ManageListTitle); try { Assert.IsTrue(ManageListTitle.Displayed); //Click Delete Icon javascript.ExecuteScript("arguments[0].click();", Delelement); //click "Yes" in delete pop up DelYes.Click(); } catch (Exception e) { Console.WriteLine(e); } //Verfication string ExpResult3 = "Software Tester 7 has been deleted"; Thread.Sleep(2000); string ActualResult3 = ActResult3.Text; if (ExpResult3 == ActualResult3) { Console.WriteLine("Test 3 Pass : Record deleted successfully"); // Helpers.SaveScreenShotClass.SaveScreenshot(CommonDriver.Driver, "Delete Listing"); } else { Console.WriteLine("Test 3 Fail: Record not deleted"); } // try // { // Assert.AreEqual("Software tester 7 has been deleted",ActResult3.Text); // Console.WriteLine("Test Fail: Skill listing still present"); // } // catch(Exception e) // { // Console.WriteLine("Test Pass: Skill listing Deleted"); // } // } //} }
public void EditListing(IWebDriver Driver) { //Click Manage Listings Menu ManageListingsMenu.Click(); Thread.Sleep(7000); //Click Edit Icon IJavaScriptExecutor javascript = (IJavaScriptExecutor)Driver; javascript.ExecuteScript("arguments[0].click();", Element); Thread.Sleep(5000); //Change Title string title1 = Title.Text; Title.Clear(); Title.SendKeys(Helpers.ExcelLib.ReadData(2, "Title")); //Click Savebutton SaveBtn.Click(); Thread.Sleep(5000); ////Verification //var title2 = "Industry Connect Software Tester"; //if (title1 == title2) //{ // Console.WriteLine("Test1 passed : title edited successfully"); // //Screenshots // //Helpers.SaveScreenShotClass.SaveScreenshot(CommonDriver.Driver, "Edit Listing"); //} //else //{ // Console.WriteLine("Test1 failed : Title not edited"); //} try { IJavaScriptExecutor jse = (IJavaScriptExecutor)Driver; IWebElement element = Driver.FindElement(By.CssSelector("div:nth-child(2) table.ui.striped.table:nth-child(1) tbody:nth-child(2) tr:nth-child(1) > td.two.wide:nth-child(3)")); jse.ExecuteScript("return arguments[0].text", element); Assert.AreEqual("Industry Connect Software Tester", element); Console.WriteLine("Test Pass: Skill listing edited"); } catch (Exception) { Console.WriteLine("Test Fail: Skill listing NOT Edited"); } }
//Delete Method public void DeleteListing(IWebDriver Driver) { //Click Manage Listings Menu ManageListingsMenu.Click(); Thread.Sleep(5000); //Identify Title of the record to be deleted IJavaScriptExecutor js3 = (IJavaScriptExecutor)Driver; js3.ExecuteScript("arguments[0].click();", ManageListTitle); //Click Delete icon IJavaScriptExecutor js2 = (IJavaScriptExecutor)Driver; js2.ExecuteScript("arguments[0].click();", Delelement); //click "Yes" in delete pop up DelYes.Click(); //Verfication try { Thread.Sleep(5000); Assert.IsTrue(ActResult3.Displayed); Console.WriteLine("Test 3 Pass : Record deleted successfully"); // Screenshot String img = Global.GlobalDefinitions.SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.Driver, "Report");//AddScreenCapture(@"E:\Dropbox\VisualStudio\Projects\Beehive\TestReports\ScreenShots\"); Base.test.Log(LogStatus.Info, "Image example: " + img); // end test. (Reports) Base.extent.EndTest(Base.test); // calling Flush writes everything to the log file (Reports) Base.extent.Flush(); } catch (Exception e) { Console.WriteLine(e); Console.WriteLine("Test 3 Pass : Record NOT deleted"); } }