Exemple #1
0
        public void Createassessment(String coursename)
        {
            //if(prop.getProperty("AssessmentTest").Trim().Equals("false"))
            //throw new SkipException("create Assessment skipped");
            try
            {
                Pages.Courses.Courses c = new Pages.Courses.Courses(driver);
                c.CourseName().SendKeys(coursename);
                c.CourseSelect().Click();
                CourseContent cc = new CourseContent(driver);
                cc.CourseWidget().Click();

                cc.CreateAssessment().Click();

                Pages.Courses.CreateAssessment ca = new Pages.Courses.CreateAssessment(driver);

                //			Test Case #01: Check all field validation message
                //logger.debug("Test Case #01: Check all field validation message");
                IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
                //TimeUnit.SECONDS.sleep(2);
                js.ExecuteScript("document.getElementById('btnAssessmentCreate').scrollIntoView();");
                ca.NextButton().Click();
                //  TimeUnit.SECONDS.sleep(2);
                js.ExecuteScript("document.getElementById('StripDiv').scrollIntoView();");
                //Verify.verify(ca.validationMess1().Text.Equals("Title is required"));
                Assert.AreEqual(ca.ValidationMess1().Text, "Title is required");
                Assert.AreEqual(ca.ValidationMess2().Text, "Time limit is required");
                Assert.AreEqual(ca.ValidationMess3().Text, "Start Date is required");
                Assert.AreEqual(ca.ValidationMess4().Text, "End Date is required");
                Assert.AreEqual(ca.ValidationMess6().Text, "Questions Count is required");
                Assert.AreEqual(ca.ValidationMess5().Text, "Pass Percentage is required");

                //			Test Case #02: Check the date validation by checking from date is greater
                //logger.debug("Test Case #02: Check the date validation by checking from date is greater");
                ca.Title().SendKeys(prop.getProperty("assessmentTitle"));
                ca.TimeLimit().SendKeys(prop.getProperty("assessmenttimeLimit"));
                ca.StartDate().SendKeys(prop.getProperty("assessmentstartDateT1"));
                ca.EndDate().SendKeys(prop.getProperty("assessmentendDateT1"));
                ca.PassPercentage().SendKeys(prop.getProperty("assessmentpassPercentage"));
                ca.QuestionsCount().SendKeys(prop.getProperty("assessmentquestionsCount"));
                ca.MaxAttempts().SendKeys(prop.getProperty("assessmentmaxAttempts"));
                ca.NextButton().Click();
                Assert.AreEqual(ca.ValidationMess1().Text, "End Date must be greaterthan startdate");


                //			Test Case #03: Check the previous date validation for start date and end date.
                //logger.debug("Test Case #03: Check the previous date validation for start date and end date");
                ca.Title().Clear();
                ca.TimeLimit().Clear();
                ca.StartDate().Clear();
                ca.EndDate().Clear();
                ca.PassPercentage().Clear();
                ca.QuestionsCount().Clear();
                ca.MaxAttempts().Clear();
                ca.Title().SendKeys(prop.getProperty("assessmentTitle"));
                ca.TimeLimit().SendKeys(prop.getProperty("assessmenttimeLimit"));
                ca.StartDate().SendKeys(prop.getProperty("assessmentstartDateT2"));
                ca.EndDate().SendKeys(prop.getProperty("assessmentendDateT2"));
                ca.PassPercentage().SendKeys(prop.getProperty("assessmentpassPercentage"));
                ca.QuestionsCount().SendKeys(prop.getProperty("assessmentquestionsCount"));
                ca.MaxAttempts().SendKeys(prop.getProperty("assessmentmaxAttempts"));
                js.ExecuteScript("document.getElementById('btnAssessmentCreate').scrollIntoView();");
                ca.NextButton().Click();
                js.ExecuteScript("document.getElementById('StripDiv').scrollIntoView();");
                Assert.AreEqual(ca.ValidationMess1().Text, "Start Date can not be previous date");
                Assert.AreEqual(ca.ValidationMess2().Text, "End Date can not be previous date");

                //			Assessment creation with data
                //logger.debug("Creating assessment with data");
                ca.Title().Clear();
                ca.TimeLimit().Clear();
                ca.StartDate().Clear();
                ca.EndDate().Clear();
                ca.PassPercentage().Clear();
                ca.QuestionsCount().Clear();
                ca.MaxAttempts().Clear();
                ca.Title().SendKeys(prop.getProperty("assessmentTitle"));
                ca.TimeLimit().SendKeys(prop.getProperty("assessmenttimeLimit"));
                ca.StartDate().SendKeys(prop.getProperty("assessmentstartDate"));
                ca.EndDate().SendKeys(prop.getProperty("assessmentendDate"));
                ca.PassPercentage().SendKeys(prop.getProperty("assessmentpassPercentage"));
                ca.QuestionsCount().SendKeys(prop.getProperty("assessmentquestionsCount"));
                ca.MaxAttempts().SendKeys(prop.getProperty("assessmentmaxAttempts"));
                js.ExecuteScript("document.getElementById('btnAssessmentCreate').scrollIntoView();");
                ca.NextButton().Click();
            }
            catch (Exception e)
            {
                //logger.error(e.getMessage());
                screenShotObj.GetScreenshot(driver, "creatingAssessment");
            }
        }