public void MycourseTest(string coursename) { try { Pages.Courses.Courses c = new Pages.Courses.Courses(driver); System.Threading.Thread.Sleep(2000); c.CourseName().SendKeys(coursename); c.CourseSelect().Click(); CourseContent cc = new CourseContent(driver); System.Threading.Thread.Sleep(2000); cc.CourseWidget().Click(); cc.CreateSurvey().Click(); CreateSurvey cs = new CreateSurvey(driver); IJavaScriptExecutor js = (IJavaScriptExecutor)driver; // Test Case #01: Empty fields validation //logger.debug("Test Case #01: Empty fields validation"); _test = _extent.StartTest("Test Case #01: Empty fields validation in Survey create"); cs.NextButton().Click(); } catch (Exception e) { } }
public void createSurvey(string coursename) { if (prop.getProperty("surveyTest").Trim().Equals("false")) { Assert.Ignore("Survey create omitted."); } try { Pages.Courses.Courses c = new Pages.Courses.Courses(driver); System.Threading.Thread.Sleep(2000); c.CourseName().SendKeys(coursename); c.CourseSelect().Click(); CourseContent cc = new CourseContent(driver); System.Threading.Thread.Sleep(2000); cc.CourseWidget().Click(); cc.CreateSurvey().Click(); CreateSurvey cs = new CreateSurvey(driver); IJavaScriptExecutor js = (IJavaScriptExecutor)driver; // Test Case #01: Empty fields validation //logger.debug("Test Case #01: Empty fields validation"); _test = _extent.StartTest("Test Case #01: Empty fields validation in Survey create"); cs.NextButton().Click(); Assert.AreEqual(cs.ValidationMess1().Text, "Title is required"); //Assert.AreEqual(cs.ValidationMess2().Text, "Start Date is required"); //Assert.AreEqual(cs.ValidationMess3().Text, "End Date is required"); _test.Log(LogStatus.Pass, "Assert Pass as condition is true"); _extent.EndTest(_test); // Test Case #02: Start date is greater than end date validation check //logger.debug("Test Case #02: Start date is greater than end date validation check"); //cs.Title().SendKeys(prop.getProperty("surveyTitle")); //cs.StartDate().SendKeys(prop.getProperty("SurveystartDateT1")); //cs.EndDate().SendKeys(prop.getProperty("SurveyendDateT1")); //cs.NextButton().Click(); //Assert.AreEqual(cs.ValidationMess1().Text, "End Date must be greaterthan startdate"); //// Test Case #03: previous date validation for start and end date ////logger.debug("Test Case #03: previous date validation for start and end date"); //cs.title().clear(); //cs.startDate().clear(); //cs.endDate().clear(); //cs.title().sendKeys(prop.getProperty("surveyTitle")); //cs.startDate().sendKeys(prop.getProperty("SurveystartDateT2")); //cs.endDate().sendKeys(prop.getProperty("SurveyendDateT2")); //TimeUnit.SECONDS.sleep(2); //js.executeScript("document.getElementById('btnAssessmentCreate').scrollIntoView();"); //cs.nextButton().click(); //Assert.assertEquals(cs.validationMess1().getText(), "Start Date can not be previous date"); //Assert.assertEquals(cs.validationMess2().getText(), "End Date can not be previous date"); // Test Case #04: correct values //logger.debug("Test Case #04: correct values"); //cs.title().clear(); //cs.startDate().clear(); //cs.endDate().clear(); _test = _extent.StartTest("Test Case #02: Valid data"); cs.Title().SendKeys(prop.getProperty("surveyTitle")); //cs.StartDate().sendKeys(prop.getProperty("SurveystartDate")); //cs.endDate().sendKeys(prop.getProperty("SurveyendDate")); js.ExecuteScript("document.getElementById('btnAssessmentCreate').scrollIntoView();"); cs.NextButton().Click(); _test.Log(LogStatus.Pass, "Assert Pass as condition is true"); _extent.EndTest(_test); } catch (Exception e) { //logger.error(e.getMessage()); screenShotObj.GetScreenshot(driver, "createSurvey"); _test.Log(LogStatus.Fail, "Assert Fail as condition is false"); _extent.EndTest(_test); } _extent.Flush(); _extent.Close(); }
public void createQuestion() { try { Pages.Courses.Courses c = new Pages.Courses.Courses(driver); c.CourseSelect().Click(); CourseContent cc = new CourseContent(driver); cc.CourseWidget().Click(); //TimeUnit.SECONDS.sleep(3); cc.CreateSurvey().Click(); CreateSurvey cs = new CreateSurvey(driver); // Test Case #01: Empty fields validation //logger.debug("Test Case #01: Empty fields validation"); //TimeUnit.SECONDS.sleep(2); _test = _extent.StartTest("Test Case #01: Empty fields validation"); cs.NextButton().Click(); //TimeUnit.SECONDS.sleep(2); Assert.AreEqual(cs.ValidationMess1().Text, "Title is required"); Assert.AreEqual(cs.ValidationMess2().Text, "Start Date is required"); Assert.AreEqual(cs.ValidationMess3().Text, "End Date is required"); // Test Case #02: Start date is greater than end date validation check //logger.debug("Test Case #02: Start date is greater than end date validation check"); //TimeUnit.SECONDS.sleep(2); cs.Title().SendKeys("auto"); cs.StartDate().SendKeys("07/29/2017"); cs.EndDate().SendKeys("07/27/2017"); cs.NextButton().Click(); //TimeUnit.SECONDS.sleep(2); Assert.AreEqual(cs.ValidationMess1().Text, "End Date must be greaterthan startdate"); // Test Case #03: previous date validation for start and end date //logger.debug("Test Case #03: previous date validation for start and end date"); //TimeUnit.SECONDS.sleep(2); cs.Title().Clear(); cs.StartDate().Clear(); cs.EndDate().Clear(); cs.Title().SendKeys("auto"); cs.StartDate().SendKeys("07/20/2017"); cs.EndDate().SendKeys("07/21/2017"); cs.NextButton().Click(); //TimeUnit.SECONDS.sleep(2); Assert.AreEqual(cs.ValidationMess1().Text, "Start Date can not be previous date"); Assert.AreEqual(cs.ValidationMess2().Text, "End Date can not be previous date"); // Test Case #04: correct values //logger.debug("Test Case #04: correct values"); //TimeUnit.SECONDS.sleep(2); cs.Title().Clear(); cs.StartDate().Clear(); cs.EndDate().Clear(); cs.Title().SendKeys("auto"); cs.StartDate().SendKeys("07/28/2017"); cs.EndDate().SendKeys("07/31/2017"); cs.NextButton().Click(); } catch (Exception e) { //logger.error(e.getMessage()); screenShotObj.GetScreenshot(driver, "CreateSurvey"); } }