/// Purpose : To Create TrueFalse question public string CreateTrueFalseQuestion() { try { string questionName = GenericHelper.GenerateUniqueVariable("TF"); GenericHelper.WaitUntilElement(By.Id("_ctl1_txtQuestionLabel")); WebDriver.FindElement(By.Id("_ctl1_txtQuestionLabel")).SendKeys(questionName); WebDriver.SwitchTo().Frame("_ctl1_ifrmEditor_A"); GenericHelper.WaitUntilElement(By.Id("viewsource")); WebDriver.FindElement(By.Id("viewsource")).Click(); WebDriver.FindElement(By.Id("ucEditorA_textarea")).SendKeys("TF"); GenericHelper.SelectWindow("Create New Question"); WebDriver.SwitchTo().Frame("frmSelectQuestion"); WebDriver.FindElement(By.Id("imgReturnh")).SendKeys(""); WebDriver.FindElement(By.Id("imgReturnh")).Click(); _contentBrowserMainUxPage.ClickAddAndClose(); if (GenericHelper.IsPopUpClosed(2)) { return(questionName); } else { return(null); } } catch (Exception e) { GenericHelper.Logs(e.ToString(), "FAILED"); throw new Exception(e.ToString()); } }
//Purpose: to Create PostTest for SSP public void CreatePostTestSsp(string posttestName) { GenericHelper.WaitUntilElement(By.Id("cmdTabAssessmentNext")); WebDriver.FindElement(By.Id("txtAssname")).SendKeys(GenericHelper.GenerateUniqueVariable("BDD_postest")); WebDriver.FindElement(By.Id("cmdTabAssessmentNext")).Click(); GenericHelper.WaitUntilElement(By.Id("cmdTabTopicsNext")); WebDriver.SwitchTo().Frame("frmTopic"); WebDriver.FindElement(By.PartialLinkText("Add Questions")).Click(); if (GenericHelper.IsElementPresent(By.PartialLinkText("Browse Skills Framework"))) { WebDriver.FindElement(By.PartialLinkText("Browse Skills Framework")).Click(); } else { WebDriver.FindElement(By.PartialLinkText("Browse Skill Framework")).Click(); } Thread.Sleep(2000); GenericHelper.SelectWindow("Select Questions"); Thread.Sleep(2000); WebDriver.SwitchTo().Frame("_ctl0_PopupPageContent_ifrmLeft"); WebDriver.FindElement(By.Id("grdSkillStandardAlignedAssets$_ctrl0")).Click(); GenericHelper.SelectWindow("Select Questions"); WebDriver.FindElement(By.Id("_ctl0_PopupPageContent_imgBtnAdd_Close")).Click(); //GenericHelper.IsPopUpClosed("Select Questions"); WebDriver.SwitchTo().Window(WebDriver.WindowHandles.First()); GenericHelper.WaitUntilElement(By.Id("cmdTabTopicsFinish")); WebDriver.FindElement(By.Id("cmdTabTopicsFinish")).Click(); Thread.Sleep(2000); }
/// <summary> /// Purpose: To Search and Add Course From Catalog /// </summary> public string AddCourseInCatalog(string courseType) { string courseName = string.Empty; GenericHelper.SelectWindow("Global Home"); WebDriver.SwitchTo().Frame(1); if (courseType.Equals("ProductTypeProg")) { GenericHelper.WaitUntilElement(By.Id("rndDiscipline")); WebDriver.FindElement(By.Id("rndDiscipline")).Click(); new SelectElement(WebDriver.FindElement(By.Id("drdDiscipline"))).SelectByText("Art"); courseName = GenericHelper.GenerateUniqueVariable("PRGCOURSE"); } if (courseType.Equals("MasterCourse")) { GenericHelper.WaitUntilElement(By.Id("txtProductTextBook")); WebDriver.FindElement(By.Id("txtProductTextBook")).Clear(); WebDriver.FindElement(By.Id("txtProductTextBook")).SendKeys("¡Anda! Curso elemental, 1e"); courseName = GenericHelper.GenerateUniqueVariable("INSCOURSE"); } GenericHelper.WaitUntilElement(By.CssSelector("span > span")); WebDriver.FindElement(By.CssSelector("span > span")).Click(); //Purpose: To Search Course From Catalog ToSearchCourseInCatalog(courseType); GenericHelper.WaitUntilElement(By.Id("txtProductName")); WebDriver.FindElement(By.Id("txtProductName")).Clear(); WebDriver.FindElement(By.Id("txtProductName")).SendKeys(courseName); GenericHelper.WaitUntilElement(By.Id("txtDesc")); WebDriver.FindElement(By.Id("txtDesc")).Clear(); WebDriver.FindElement(By.Id("txtDesc")).SendKeys("BDD Course Description"); GenericHelper.WaitUntilElement(By.CssSelector("#btnFinish > span > span")); WebDriver.FindElement(By.CssSelector("#btnFinish > span > span")).Click(); return(courseName); }
public void WhenICreateSkillStudyPlanPreTestPostTest() { try { string sppName = GenericHelper.GenerateUniqueVariable("SSP"); _drtDefaultUxPage.EnterSSPName(sppName); //Purpose: PreTest Creation _drtDefaultUxPage.ClickCreateTestForPretest(); _assessmentPage.CreatePreTestSsp(GenericHelper.GenerateUniqueVariable("BDD_pretest")); //-------Purpose: PostTest Creation : We are not adding Post Test usecase as it is not necessary--------// //GenericHelper.WaitUntilElement(By.ClassName("DRT_addSmal1")); //WebDriver.FindElement(By.ClassName("DRT_addSmal1")).Click(); //WebDriver.FindElement(By.ClassName("DRT_addSmal1")).SendKeys(" "); //Thread.Sleep(3000); //_assessmentPage.CreatePostTestSsp(GenericHelper.GenerateUniqueVariable("BDD_posttest")); //-------Purpose: PostTest Creation : We are not adding Post Test usecase as it is not necessary--------// //Purpose: Saving SSP _drtDefaultUxPage.SaveSSP(); DatabaseTools.UpdateActivity(Enumerations.ActivityType.SkillStudyPlan, sppName); } catch (Exception e) { GenericHelper.Logs(e.ToString(), "FAILED"); throw e; } }
/// Purpose : To Create TrueFalse question public string CreateTrueFalseQuestion() { try { string questionName = GenericHelper.GenerateUniqueVariable("TF"); GenericHelper.WaitUtilWindow("Create True/False"); GenericHelper.SelectWindow("Create True/False"); WebDriver.FindElement(By.Id("_ctl1_txtQuestionLabel")).SendKeys(questionName); WebDriver.SwitchTo().Frame("_ctl1_ifrmEditor_A"); WebDriver.FindElement(By.Id("viewsource")).Click(); WebDriver.FindElement(By.Id("ucEditorA_textarea")).SendKeys("TF"); GenericHelper.SelectWindow("Create True/False"); WebDriver.FindElement(By.Id("imgReturnh")).Click(); Thread.Sleep(4000); GenericHelper.IsPopUpClosed(2); GenericHelper.SelectDefaultWindow(); if (GenericHelper.VerifySuccesfullMessage("Question created successfully.")) { return(questionName); } else { return(null); } } catch (Exception e) { GenericHelper.Logs(e.ToString(), "FAILED"); throw new Exception(e.ToString()); } }
// method to fill the details for multiple choice questions public void ToFillTheDetailsForMultiple() { try { GenericHelper.SelectWindow("Create Multiple Choice"); GenericHelper.WaitUntilElement(By.Id("_ctl1_txtQuestionLabel")); string questionName = GenericHelper.GenerateUniqueVariable("Multiple_Choice"); DatabaseTools.UpdateQuestions(Enumerations.QuestionType.MultipleChoice, questionName); WebDriver.FindElement(By.Id("_ctl1_txtQuestionLabel")).SendKeys(questionName); WebDriver.SwitchTo().Frame("_ctl1_ifrmEditor_A"); GenericHelper.WaitUntilElement(By.Id("viewsource")); WebDriver.FindElement(By.Id("viewsource")).Click(); GenericHelper.WaitUntilElement(By.Id("ucEditorA_textarea")); WebDriver.FindElement(By.Id("ucEditorA_textarea")).SendKeys("Which is the best framework for automation testing"); GenericHelper.WaitUntilElement(By.Id("viewsource")); WebDriver.FindElement(By.Id("viewsource")).Click(); WebDriver.SwitchTo().DefaultContent(); GenericHelper.WaitUntilElement(By.Id("spnAnswer")); WebDriver.FindElement(By.Id("spnAnswer")).Click(); GenericHelper.WaitUntilElement(By.Id("_ctl1_dgdChoices__ctl2_txtChoice")); WebDriver.FindElement(By.Id("_ctl1_dgdChoices__ctl2_txtChoice")).SendKeys("BDD"); WebDriver.FindElement(By.Id("_ctl1_dgdChoices__ctl3_txtChoice")).SendKeys("TDD"); WebDriver.FindElement(By.Id("_ctl1_dgdChoices__ctl4_txtChoice")).SendKeys("ATDD"); WebDriver.FindElement(By.Id("_ctl1_dgdChoices__ctl5_txtChoice")).SendKeys("New One"); WebDriver.SwitchTo().DefaultContent(); WebDriver.FindElement(By.Id("imgReturnf")).Click(); //GenericHelper.IsPopUpClosed("Create Multiple Choice"); } catch (Exception e) { GenericHelper.Logs(e.ToString(), "Failed"); } }
public void ThenICreateStudyPlanFromCourseMaterialTab() { try { GenericHelper.WaitUtilWindow("Course Materials"); _contentLibraryUxPage.ClickAddCourseMaterialsButton(); if (!_contentLibraryUxPage.IsStudyPlanOptionPresent()) { GenericTestStep.StepToNavigateToTheTab("Preferences"); _generalPreferencesPage.SelectSkillsAndStandards(); _standardSkillPreferencesPage.SelectNeitherRadioButtonAndSave(); GenericTestStep.StepToNavigateToTheTab("Course Materials"); _contentLibraryUxPage.GetControlToLeftFrame(); _contentLibraryUxPage.ClickAddCourseMaterialsButton(); } //create study plan string studyPlanName = GenericHelper.GenerateUniqueVariable("SP"); _contentLibraryUxPage.StudyPlanCreation(studyPlanName); _contentLibraryUxPage.GetControlToLeftFrame(); string SPName = DatabaseTools.GetActivityName(Enumerations.ActivityType.StudyPlan); GenericTestStep.StepToAddTheActivityToMyCourse(SPName); } catch (Exception e) { GenericHelper.Logs(e.ToString(), "FAILED"); Assert.Fail(e.ToString()); } }
// method to fill the details for multiple choice questions public void ToCreateFillInTheBlanks() { try { GenericHelper.SelectWindow("Create Fill in the Blank"); GenericHelper.WaitUntilElement(By.Id("_ctl1_txtQuestionLabel")); string questionName = GenericHelper.GenerateUniqueVariable("FillintheBlank"); DatabaseTools.UpdateQuestions(Enumerations.QuestionType.FillInTheBlank, questionName); WebDriver.FindElement(By.Id("_ctl1_txtQuestionLabel")).SendKeys(questionName); GenericHelper.WaitUntilElement(By.XPath("//div[@id='cmdAddblank']/img[contains(@src,'/images/QuestionLibrary/icn_add.gif')]")); WebDriver.FindElement(By.XPath("//div[@id='cmdAddblank']/img[contains(@src,'/images/QuestionLibrary/icn_add.gif')]")).Click(); GenericHelper.WaitUntilElement(By.LinkText("Add at Bottom")); WebDriver.FindElement(By.LinkText("Add at Bottom")).Click(); GenericHelper.WaitUntilElement(By.XPath("//img[@src='../../images/QuestionLibrary/icn_add.gif']")); WebDriver.FindElement(By.XPath("//img[@src='../../images/QuestionLibrary/icn_add.gif']")).Click(); GenericHelper.WaitUntilElement(By.LinkText("Add at Top")); WebDriver.FindElement(By.LinkText("Add at Top")).Click(); GenericHelper.WaitUntilElement(By.Id("_ctl1_dgdChoices__ctl2_txtText")); WebDriver.FindElement(By.Id("_ctl1_dgdChoices__ctl2_txtText")).SendKeys("WebDriver is the father of"); GenericHelper.WaitUntilElement(By.Id("_ctl1_dgdChoices__ctl3_txtText")); WebDriver.FindElement(By.Id("_ctl1_dgdChoices__ctl3_txtText")).SendKeys("Remote Control"); WebDriver.SwitchTo().DefaultContent(); GenericHelper.WaitUntilElement(By.Id("imgReturnf")); WebDriver.FindElement(By.Id("imgReturnf")).Click(); // GenericHelper.IsPopUpClosed("Create Fill in the Blank"); } catch (Exception e) { GenericHelper.Logs(e.ToString(), "Failed"); } }
// Purpose: Create a Class Using ML public void ToCreateClassUsingML() { try { int rowNo = 1; WebDriver.WindowHandles.Any(item => WebDriver.SwitchTo().Window(item).Title == "Create Class"); WebDriver.SwitchTo().Frame("iframeCreateClass"); Classname = GenericHelper.GenerateUniqueVariable("ClassML"); DatabaseTools.UpdateClass(Enumerations.ClassType.NovaNETMasterLibrary, Classname); WebDriver.FindElement(By.Id("clsClassInformation_txtNewClassName")).SendKeys(Classname); WebDriver.SwitchTo().DefaultContent(); GenericHelper.WaitUntilElement(By.Id("btnNext")); WebDriver.FindElement(By.Id("btnNext")).Click(); WebDriver.SwitchTo().Frame("iframeCreateClass"); GenericHelper.WaitUntilElement(By.Id("clsClassInformation_rdbChooseProduct")); WebDriver.FindElement(By.Id("clsClassInformation_rdbChooseProduct")).Click(); WebDriver.SwitchTo().DefaultContent(); WebDriver.FindElement(By.Id("btnNext")).Click(); Thread.Sleep(2000); WebDriver.SwitchTo().Frame("iframeCreateClass"); string className = WebDriver.FindElement(By.XPath("//table[@id='tblCourseList']/tbody/tr[" + rowNo + "]")).Text.Trim(); string dbmlName = DatabaseTools.GetCourse(Enumerations.CourseType.MasterLibrary).Trim(); if (className == dbmlName) { WebDriver.FindElement(By.XPath("//table[@id='tblCourseList']/tbody/tr[" + rowNo + "]/td/input[@id='selectcheckbox']")).Click(); } while (className != dbmlName) { rowNo = rowNo + 1; className = WebDriver.FindElement(By.XPath("//table[@id='tblCourseList']/tbody/tr[" + rowNo + "]")).Text.Trim(); if (className == dbmlName) { WebDriver.FindElement(By.XPath("//table[@id='tblCourseList']/tbody/tr[" + rowNo + "]/td/input[@id='selectcheckbox']")).Click(); } } WebDriver.SwitchTo().DefaultContent(); WebDriver.FindElement(By.Id("btnNext")).Click(); GenericHelper.WaitUntilElement(By.Id("btnNext")); WebDriver.FindElement(By.Id("btnNext")).Click(); GenericHelper.WaitUntilElement(By.Id("btnFinish")); WebDriver.FindElement(By.Id("btnFinish")).Click(); GenericHelper.IsPopUpClosed(3); ToSearchForAssigned((Enumerations.ClassType.NovaNETMasterLibrary)); WebDriver.Close(); GenericHelper.IsPopUpClosed(2); } catch (Exception e) { GenericHelper.Logs(e.ToString(), "FAILED"); bool isCreateClassWindowPresent = GenericHelper.IsPopUpWindowPresent("Create Class"); if (isCreateClassWindowPresent) { GenericHelper.SelectWindow("Create Class"); WebDriver.Close(); } throw new Exception(e.ToString()); } }
//Purpose: To Copy HED Autohored Course public void CopyCourse(string copyCourseName) { try { if (copyCourseName.Equals("Master")) { GenericHelper.SelectWindow("Copy as Master Course"); courseName = GenericHelper.GenerateUniqueVariable("MySpanishLab"); } if (copyCourseName.Equals("Testing")) { GenericHelper.SelectWindow("Copy as Testing Course"); courseName = GenericHelper.GenerateUniqueVariable("TestingCourse"); } GenericHelper.WaitUntilElement(By.Id("txtCourseName")); WebDriver.FindElement(By.Id("txtCourseName")).Clear(); WebDriver.FindElement(By.Id("txtCourseName")).SendKeys(copyCourseName); WebDriver.FindElement(By.Id("imgbtnSave")).Click(); Thread.Sleep(3000); bool isCourseCopyWindowClosed = GenericHelper.IsPopUpClosed(2); if (isCourseCopyWindowClosed) { if (copyCourseName.Contains("MySpanishLab")) { GenericHelper.Logs(string.Format("HED Authored Course '{0}' has been copied successfully.", copyCourseName), "PASSED"); DatabaseTools.UpdateCourse(Enumerations.CourseType.MySpanishLabMasterCourse, copyCourseName); } else if (copyCourseName.Contains("TestingCourse")) { GenericHelper.Logs(string.Format("Authored Course '{0}' has been copied successfully.", copyCourseName), "PASSED"); DatabaseTools.UpdateCourse(Enumerations.CourseType.TestingCourse, copyCourseName); } else { GenericHelper.Logs(string.Format("Authored Course '{0}' has been copied successfully.", copyCourseName), "PASSED"); DatabaseTools.UpdateCourse(Enumerations.CourseType.AuthoredMasterLibrary, copyCourseName); } } else { GenericHelper.Logs(string.Format("Authored Course '{0}' has not been copied successfully.", copyCourseName), "FAILED"); } } catch (Exception e) { GenericHelper.Logs(e.ToString(), "FAILED"); bool isCopyasMasterCourseWindowPresent = GenericHelper.IsPopUpWindowPresent("Copy as Master Course"); if (isCopyasMasterCourseWindowPresent) { GenericHelper.SelectWindow("Copy as Master Course"); WebDriver.Close(); } Assert.Fail(e.ToString()); } }
// Purpose - Method To Create a Class Using Template public void ToCreateClass() { int tableNo = 1; Thread.Sleep(3000); WebDriver.WindowHandles.Any(item => WebDriver.SwitchTo().Window(item).Title == "Create Class"); WebDriver.SwitchTo().Frame("iframeCreateClass"); Classname = GenericHelper.GenerateUniqueVariable("ClassTemp"); GenericHelper.WaitUntilElement(By.Id("clsClassInformation_txtNewClassName")); WebDriver.FindElement(By.Id("clsClassInformation_txtNewClassName")).SendKeys(Classname); WebDriver.SwitchTo().DefaultContent(); GenericHelper.WaitUntilElement(By.Id("btnNext")); WebDriver.FindElement(By.Id("btnNext")).Click(); Thread.Sleep(2000); WebDriver.SwitchTo().Frame("iframeCreateClass"); GenericHelper.WaitUntilElement(By.Id("clsClassInformation_rdbChooseOrganisation")); if (!WebDriver.FindElement(By.Id("clsClassInformation_rdbChooseOrganisation")).Selected) { GenericHelper.Logs("Class creation option is disabled", "FAILED"); WebDriver.Close(); throw new Exception("Class creation option is disabled"); } WebDriver.FindElement(By.Id("clsClassInformation_rdbChooseOrganisation")).Click(); WebDriver.SwitchTo().DefaultContent(); GenericHelper.WaitUntilElement(By.Id("btnNext")); WebDriver.FindElement(By.Id("btnNext")).Click(); Thread.Sleep(2000); WebDriver.SwitchTo().Frame("iframeCreateClass"); string className = WebDriver.FindElement(By.XPath("//div[@id='clsClassContentList_pnlcontrolListContentType1']/table[" + tableNo + "]")).Text.Trim(); string templateName = DatabaseTools.GetTemplate(); if (className == templateName) { WebDriver.FindElement(By.XPath("//div[@id='clsClassContentList_pnlcontrolListContentType1']/table[" + tableNo + "]/tbody/tr/td/input[@id='selectRadio']")).Click(); } while (className != templateName) { tableNo = tableNo + 1; className = WebDriver.FindElement(By.XPath("//div[@id='clsClassContentList_pnlcontrolListContentType1']/table[" + tableNo + "]")).Text.Trim(); if (className == templateName) { WebDriver.FindElement(By.XPath("//div[@id='clsClassContentList_pnlcontrolListContentType1']/table[" + tableNo + "]/tbody/tr/td/input[@id='selectRadio']")).Click(); } } WebDriver.SwitchTo().DefaultContent(); WebDriver.FindElement(By.Id("btnNext")).Click(); GenericHelper.WaitUntilElement(By.Id("btnNext")); WebDriver.FindElement(By.Id("btnNext")).Click(); GenericHelper.WaitUntilElement(By.Id("btnFinish")); WebDriver.FindElement(By.Id("btnFinish")).Click(); GenericHelper.IsPopUpClosed("Create Class"); ToSearchForAssigned((Enumerations.ClassType.Template)); DatabaseTools.UpdateClass(Enumerations.ClassType.Template, Classname); }
//Purpose: To creat CS users public void Createusers(Table table) { try { GenericHelper.WaitUntilElement(By.Id("frm")); WebDriver.SwitchTo().Frame("frm"); WebDriver.FindElement(By.Id("lblCreateUser")).Click(); // Purpose: Username and Password will be written to DB string username = string.Empty; switch (((string[])(table.Rows[0].Values))[1]) { case "Teacher": WebDriver.FindElement(By.Id("lblins")).Click(); username = GenericHelper.GenerateUniqueVariable("CsTeach"); DatabaseTools.UpdateUserDb(Enumerations.UserType.CsTeacher, username, "bdd_pwd123", "*****@*****.**", 5, true); break; case "Student": WebDriver.FindElement(By.Id("lblStudent")).Click(); username = GenericHelper.GenerateUniqueVariable("CsStud"); DatabaseTools.UpdateUserDb(Enumerations.UserType.CsStudent, username, "bdd_pwd123", "*****@*****.**", 6, true); break; case "OrgAdmin": WebDriver.FindElement(By.Id("lblAdmin")).Click(); username = GenericHelper.GenerateUniqueVariable("OrgAdmin"); DatabaseTools.UpdateUserDb(Enumerations.UserType.CsOrganizationAdmin, username, "bdd_pwd123", "*****@*****.**", 7, true); break; } GenericHelper.SelectWindow("Add User"); ((string[])(table.Rows[0].Values))[1] = username; ((string[])(table.Rows[1].Values))[1] = "bdd_pwd123"; ((string[])(table.Rows[2].Values))[1] = username; ((string[])(table.Rows[3].Values))[1] = username; ((string[])(table.Rows[4].Values))[1] = "*****@*****.**"; foreach (var tableRow in table.Rows) { GenericHelper.WaitUntilElement(By.Id(tableRow["Field"])); WebDriver.FindElement(By.Id(tableRow["Field"])).SendKeys(tableRow["Value"]); } WebDriver.FindElement(By.Id("imgBtnSave")).Click(); GenericHelper.IsPopUpClosed(3); } catch (Exception e) { GenericHelper.Logs(e.ToString(), "FAILED"); if (GenericHelper.IsPopUpWindowPresent("Add User")) { GenericHelper.SelectWindow("Add User"); WebDriver.Close(); } throw new Exception(e.ToString()); } }
//Purpose: To Create Program public void CreateProgram() { try { string programName = GenericHelper.GenerateUniqueVariable("BDD_Pgm"); string emptyCourse = DatabaseTools.GetEnabledCourse(Enumerations.CourseType.EmptyCourse); Thread.Sleep(1000); GenericHelper.WaitUntillWindowAndElement("Create New Program", By.ClassName("textfield2")); WebDriver.FindElement(By.ClassName("textfield2")).SendKeys(programName); GenericHelper.WaitUntilElement(By.Id("drpEmptyClass")); _iElement = WebDriver.FindElement(By.Id("drpEmptyClass")); SelectElement selectElement1 = new SelectElement(_iElement); try { selectElement1.SelectByText(emptyCourse); } catch (Exception) { GenericHelper.Logs("Empty Class not present while creating Program.", "FAILED"); throw new Exception("Empty Class not present while creating Program."); } WebDriver.FindElement(By.Id("chkbxEnablePrgAssociationToAdmin")).Click(); WebDriver.FindElement(By.Id("chkbxEnablePrgAssociationToTech")).Click(); GenericHelper.WaitUntilElement(By.Id("chkbxEnableStdManagement")); WebDriver.FindElement(By.Id("chkbxEnableTeachBadgeView")).Click(); WebDriver.FindElement(By.Id("chkbxEnableStdManagement")).Click(); GenericHelper.WaitUntilElement(By.Id("imgbtnSave")); WebDriver.FindElement(By.Id("imgbtnSave")).Click(); Thread.Sleep(1000); if (GenericHelper.IsPopUpClosed(2)) { DatabaseTools.UpdateProgram(programName, emptyCourse, Enumerations.ProgramInstance.NovaNET); GenericHelper.Logs(programName + " program name is updated in DB", "PASSED"); } else { GenericHelper.Logs( "'Create New Program' not closed on clicking the save button hence progrm name is not updated in DB", "FAILED"); } } catch (Exception e) { GenericHelper.Logs(e.ToString(), "FAILED"); if (GenericHelper.IsPopUpWindowPresent("Create New Program")) { GenericHelper.SelectWindow("Create New Program"); WebDriver.Close(); } throw new Exception(e.ToString()); } }
//Purpose: to Create PreTest for SSP public void CreatePreTestSsp(string pretestName) { GenericHelper.WaitUntilElement(By.Id("cmdTabAssessmentNext")); WebDriver.FindElement(By.Id("txtAssname")).SendKeys(GenericHelper.GenerateUniqueVariable("BDD_pretest")); WebDriver.FindElement(By.Id("cmdTabAssessmentNext")).Click(); GenericHelper.WaitUntilElement(By.Id("cmdTabTopicsNext")); WebDriver.FindElement(By.PartialLinkText("Add Questions")).Click(); WebDriver.FindElement(By.XPath("//div[@id='AddQuestionsContextMenu']/table/thead/tr/td")).Click(); Thread.Sleep(2000); GenericHelper.SelectWindow("Select Questions"); WebDriver.SwitchTo().Frame("_ctl0_PopupPageContent_ifrmLeft"); GenericHelper.WaitUntilElement(By.Id("tdShowPreview")); WebDriver.FindElement( By.XPath("//TABLE[@id='grdFrameWorkSkillStandard']/tbody/tr/td[2]/table/tbody/tr/td/span/span/span")). Click(); GenericHelper.WaitUntilElement(By.Id("tdShowPreview")); if ( GenericHelper.IsElementPresent( By.XPath("//TABLE[@id='grdFrameWorkSkillStandard']/tbody/tr/td[2]/table/tbody/tr/td/span/span/span"))) { WebDriver.FindElement( By.XPath("//TABLE[@id='grdFrameWorkSkillStandard']/tbody/tr/td[2]/table/tbody/tr/td/span/span/span")) .Click(); GenericHelper.WaitUntilElement(By.Id("tdShowPreview")); } if ( GenericHelper.IsElementPresent( By.XPath("//TABLE[@id='grdFrameWorkSkillStandard']/tbody/tr/td[2]/table/tbody/tr/td/span/span/span"))) { WebDriver.FindElement( By.XPath("//TABLE[@id='grdFrameWorkSkillStandard']/tbody/tr/td[2]/table/tbody/tr/td/span/span/span")) .Click(); GenericHelper.WaitUntilElement(By.Id("tdShowPreview")); } if ( GenericHelper.IsElementPresent( By.XPath("//TABLE[@id='grdFrameWorkSkillStandard']/tbody/tr/td[2]/table/tbody/tr/td/span/span/span"))) { WebDriver.FindElement( By.XPath("//TABLE[@id='grdFrameWorkSkillStandard']/tbody/tr/td[2]/table/tbody/tr/td/span/span/span")) .Click(); GenericHelper.WaitUntilElement(By.Id("tdShowPreview")); } WebDriver.FindElement(By.Id("grdSkillStandardAlignedAssets$_ctrl0")).Click(); GenericHelper.SelectWindow("Select Questions"); WebDriver.FindElement(By.Id("_ctl0_PopupPageContent_imgBtnAdd_Close")).Click(); // GenericHelper.IsPopUpClosed("Select Questions"); WebDriver.SwitchTo().Window(WebDriver.WindowHandles.First()); GenericHelper.WaitUntilElement(By.Id("cmdTabTopicsFinish")); WebDriver.FindElement(By.Id("cmdTabTopicsFinish")).Click(); }
public void ThenItShouldShownUpTheChangesDoneInTheDefaultPreferencesOfTheActivityForTheNewlyCreatedActivity() { try { GenericTestStep.StepToNavigateToTheTab("Course Materials"); string newTest = GenericHelper.GenerateUniqueVariable("NewTest"); GenericHelper.SelectWindow("Course Materials"); _contentLibraryUxPage.ClickAddCourseMaterialsButton(); _contentLibraryUxPage.SelectWebActivity(); GenericHelper.WaitUtilWindow("Create activity"); GenericHelper.SelectDefaultWindow(); _addAssessmentPage.EnterActivityName(newTest); _addAssessmentPage.SelectRandomActivity(); _addAssessmentPage.ClickSaveAndContinue(); _randomAssessmentPage.NavigatePreferencesTab(); if (_randomAssessmentPage.GetQuestionsCount() == "2") { GenericHelper.Logs("Changes done for 'questions per page' and 'SpecifyNumberOfAttempts' in the default preferences are reflected for the new activity", "PASSED"); } else { GenericHelper.Logs("Changes done for 'questions per page' and 'SpecifyNumberOfAttempts' in the default preferences are not reflected for the new activity", "PASSED"); throw new Exception("Changes done for 'questions per page' and 'SpecifyNumberOfAttempts' in the default preferences are not reflected for the new activity"); } if (_randomAssessmentPage.verifyDefaultStyleSheetSelected() == "MSL100" && _randomAssessmentPage.GetTimeValue() == "02") { GenericHelper.Logs("Changes done for 'style sheet ' and 'Time required to complete the activity' in the default preferences are reflected for the new activity", "PASSED"); } else { GenericHelper.Logs("Changes done for 'style sheet ' and 'Time required to complete the activity' in the default preferences are not reflected for the new activity", "PASSED"); throw new Exception("Changes done for 'style sheet ' and 'Time required to complete the activity' in the default preferences are not reflected for the new activity"); } if (_randomAssessmentPage.GetValueOfThresholdScore() == "60") { GenericHelper.Logs("Changes done for 'Threshold Score' in the default preferences are reflected for the new activity", "PASSED"); } else { GenericHelper.Logs("Changes done for 'ThresholdScore' in the default preferences are not reflected for the new activity", "PASSED"); throw new Exception("Changes done for 'ThresholdScore' and in the default preferences are not reflected for the new activity"); } } catch (Exception e) { GenericHelper.Logs(e.ToString(), "FAILED"); Assert.Fail(e.ToString()); } }
//Purpose : To add new user as WSadmin public void ToCreateWSuser(string userType) { try { GenericHelper.SelectWindow("Create New User"); GenericHelper.WaitUntilElement(By.Id("txtLoginName")); WebDriver.FindElement(By.Id("txtLoginName")).Clear(); if (userType.Equals("instructor")) { userNameValue = GenericHelper.GenerateUniqueVariable("Ins"); } if (userType.Equals("student")) { userNameValue = GenericHelper.GenerateUniqueVariable("Stu"); } WebDriver.FindElement(By.Id("txtLoginName")).SendKeys(userNameValue); GenericHelper.WaitUntilElement(By.Id("txtPassword")); WebDriver.FindElement(By.Id("txtPassword")).Clear(); WebDriver.FindElement(By.Id("txtPassword")).SendKeys("password1"); GenericHelper.WaitUntilElement(By.Id("txtFirstName")); WebDriver.FindElement(By.Id("txtFirstName")).Clear(); WebDriver.FindElement(By.Id("txtFirstName")).SendKeys("auto"); GenericHelper.WaitUntilElement(By.Id("txtLastName")); WebDriver.FindElement(By.Id("txtLastName")).Clear(); WebDriver.FindElement(By.Id("txtLastName")).SendKeys("auto"); GenericHelper.WaitUntilElement(By.Id("txtEmail")); WebDriver.FindElement(By.Id("txtEmail")).Clear(); WebDriver.FindElement(By.Id("txtEmail")).SendKeys("*****@*****.**"); GenericHelper.WaitUntilElement(By.Id("imgBtnSave_Update")); WebDriver.FindElement(By.Id("imgBtnSave_Update")).Click(); GenericHelper.IsPopUpClosed(2); DatabaseTools.UpdateUserDb(Enumerations.UserType.HedWsInstructor, userNameValue, "password1", "*****@*****.**", 12, true); } catch (Exception e) { GenericHelper.Logs(e.ToString(), "FAILED"); WebDriver.Close(); Assert.Fail(string.Format("Exception of type {0} caught: {1}", e.GetType(), e.Message)); } }
//Purpose : To create District level of Organization at root public void CreateDistrictAtRootLevel() { try { Thread.Sleep(3000); GenericHelper.SelectWindow("Create Organization"); string distName = GenericHelper.GenerateUniqueVariable("BDDDist"); GenericHelper.WaitUntilElement(By.Id("txtInternalOrganisation")); WebDriver.FindElement(By.Id("txtInternalOrganisation")).SendKeys(distName); WebDriver.FindElement(By.Id("txtOrganisation")).Click(); WebDriver.FindElement(By.Id("address")).SendKeys("BDD"); WebDriver.FindElement(By.Id("City")).SendKeys("BDD"); WebDriver.FindElement(By.Id("zip")).SendKeys("12345"); WebDriver.FindElement(By.XPath("//table[@id='tblOrganisationLevel']/tbody/tr/td/input")).Click(); WebDriver.FindElement(By.XPath("//table[@id='tblOrganisationLevel']/tbody/tr[2]/td/input")).Click(); WebDriver.FindElement(By.Id("tdRemove")).Click(); WebDriver.FindElement(By.Id("imgbtnSave")).Click(); bool isWindowClosed = GenericHelper.IsPopUpClosed(2); if (isWindowClosed) { GenericHelper.Logs("'Create Organization' window closed successfully and district name updated in DB", "PASSED"); DatabaseTools.UpdateOrganizationTrue(distName, Enumerations.OrgLevelType.District); } else { GenericHelper.Logs("'Create Organization' window not closed successfully and district name not updated in DB", "FAILED"); DatabaseTools.UpdateOrganizationFalse(distName, Enumerations.OrgLevelType.District); } } catch (Exception e) { GenericHelper.Logs(e.ToString(), "FAILED"); if (GenericHelper.IsPopUpWindowPresent("Create Organization")) { GenericHelper.SelectWindow("Create Organization"); WebDriver.Close(); } throw new Exception(e.ToString()); } }
public void WhenICreateTheUserWithUserDetails(Table table) { try { // Purpose: Username and Password will be written to DB string username = string.Empty; switch (((string[])(table.Rows[0].Values))[1]) { case "Teacher": username = GenericHelper.GenerateUniqueVariable("Teach"); break; case "Student": username = GenericHelper.GenerateUniqueVariable("Stud"); break; } _newUserPage.AddNewUser(table, username); } catch (Exception e) { GenericHelper.Logs(e.ToString(), "FAILED"); if (Browser.Equals("FF") || Browser.Equals("IE")) { BackedSelenium.SelectWindow(""); } if (Browser.Equals("GC")) { GenericHelper.SelectDefaultWindow(); } IWebElement clickLogoutLink = WebDriver.FindElement((By.XPath(LogOut))); if (clickLogoutLink.Displayed && clickLogoutLink.Enabled) { WebDriver.SwitchTo().DefaultContent(); new Actions(WebDriver).Click(clickLogoutLink).Perform(); } Thread.Sleep(7000); throw new Exception(e.ToString()); } }
public void CreateCourse(string coursetype) { GenericHelper.SelectWindow("Create New Courses"); courseName = GenericHelper.GenerateUniqueVariable(coursetype); WebDriver.FindElement(By.Id("txtCourseName")).SendKeys(courseName); // Purpose: Fetch Coursename From DB WebDriver.FindElement(By.LinkText("Save")).Click(); bool isCreateCourseWindowClosed = GenericHelper.IsPopUpClosed(2); if (isCreateCourseWindowClosed) { switch (coursetype) { case "BDDML": DatabaseTools.UpdateCourse(Enumerations.CourseType.MasterLibrary, courseName); break; case "BDDCC": DatabaseTools.UpdateCourse(Enumerations.CourseType.ContainerCourse, courseName); break; case "BDDEC": DatabaseTools.UpdateCourse(Enumerations.CourseType.EmptyCourse, courseName); break; case "BDDMC": DatabaseTools.UpdateCourse(Enumerations.CourseType.MasterCourse, courseName); break; } GenericHelper.Logs("As 'Create New Courses' pop-up closed on clicking save button the course is updated in DB" + courseName, "PASSED"); } else { GenericHelper.Logs("As 'Create New Courses' pop-up not closed on clicking save button the course is not updated in DB" + courseName, "FAILED"); } WebDriver.SwitchTo().Window(WebDriver.WindowHandles.First()); GenericHelper.VerifySuccesfullMessage("New course created successfully."); }
public void WhenICreateATestUnderTestBank() { try { string testName = GenericHelper.GenerateUniqueVariable("Test"); _myTestGridUxPage.ClickCreateNewTest(); _assessmentNamePage.CreateTest(testName); for (int i = 1; i <= 5; i++) { _paperTestUxPage.SelectTrueFalseQuestion(); if (_trueFalsePage.CreateTrueFalseQuestion() != null) { GenericHelper.Logs("TF question created in Test", "PASSED"); } else { GenericHelper.Logs("TF question not created in Test", "FAILED"); throw new Exception("TF question not created in Test"); } } if (_paperTestUxPage.SaveTest()) { GenericHelper.Logs("Test Saved Successfully", "PASSED"); DatabaseTools.UpdateActivity(Enumerations.ActivityType.MyTest, testName); } else { GenericHelper.Logs("Test not Saved Successfully", "FAILED"); throw new Exception("Test not Saved Successfully"); } } catch (Exception e) { GenericHelper.Logs(e.ToString(), "FAILED"); Assert.Fail(e.ToString()); } }
public void WhenICreateTheUserAsStudent(Table table) { try { _gbRoasterDefaultPage.VerifyRosterTabClicked(); _gbRoasterDefaultPage.SelectRoasterStudentOption(); string username = GenericHelper.GenerateUniqueVariable("CsStud"); GenericHelper.SelectDefaultWindow(); _adduserPage.AddUser(table, username); bool isCreateUserPopUpclosed = GenericHelper.IsPopUpClosed(2); if (isCreateUserPopUpclosed) { DatabaseTools.UpdateUserDb(Enumerations.UserType.CsStudent, username, "bdd_pwd123", "*****@*****.**", 9, true); } } catch (Exception e) { GenericHelper.Logs(e.ToString(), "FAILED"); GenericDefinitions.ThenIClickedOnTheLogoutLinkToGetLoggedOutFromTheApplication(); Thread.Sleep(3000); throw new Exception(e.ToString()); } }
//Purpose : To create school level of Organization public void CreateSchool() { try { string orgName = GenericHelper.GenerateUniqueVariable("BDDSchool"); Thread.Sleep(2000); GenericHelper.SelectWindow("Create Organization"); GenericHelper.WaitUntilElement(By.Id("txtInternalOrganisation")); WebDriver.FindElement(By.Id("txtInternalOrganisation")).SendKeys(orgName); WebDriver.FindElement(By.Id("txtOrganisation")).Click(); WebDriver.FindElement(By.Id("address")).SendKeys("BDD"); WebDriver.FindElement(By.Id("City")).SendKeys("BDD"); WebDriver.FindElement(By.Id("zip")).SendKeys("12345"); WebDriver.FindElement(By.Id("imgbtnSave")).Click(); bool isWindowClosed = GenericHelper.IsPopUpClosed(2); if (isWindowClosed) { GenericHelper.Logs("Organization has been created successfully,School name updated in DB", "PASSED"); DatabaseTools.UpdateOrganizationTrue(orgName, Enumerations.OrgLevelType.School); } else { GenericHelper.Logs("'Create Organization' window not closed no clicking Save button,hence School name not updated in DB", "FAILED"); DatabaseTools.UpdateOrganizationFalse(orgName, Enumerations.OrgLevelType.School); } } catch (Exception e) { GenericHelper.Logs(e.ToString(), "FAILED"); if (GenericHelper.IsPopUpWindowPresent("Create Organization")) { GenericHelper.SelectWindow("Create Organization"); WebDriver.Close(); } throw new Exception(e.ToString()); } }
//Purpose: Method to select Licenses Tab public void ToCreateTemplate() { string templateName = GenericHelper.GenerateUniqueVariable("Template"); try { GenericHelper.SelectWindow("Add Template"); GenericHelper.WaitUntilElement(By.Id("txtTempname")); WebDriver.FindElement(By.Id("txtTempname")).SendKeys(templateName); WebDriver.FindElement(By.Id("txtTempDesc")).SendKeys(GenericHelper.GenerateUniqueVariable("DescriptionTemplate")); GetCcNameandMatch(); WebDriver.FindElement(By.Id("imgbtnAddTemplate")).Click(); Thread.Sleep(60000);//This I have added because of page get submit bool isCreateTemplateWindowClosed = GenericHelper.IsPopUpClosed(3); if (isCreateTemplateWindowClosed) { GenericHelper.Logs("'Add Template' window has been closed successfully.", "PASSED"); //Purpose: If Create Template' window has been closed successfull then update Template Name in DB DatabaseTools.UpdateTemplate(templateName); } else { GenericHelper.Logs("'Add Template' window has not been closed after the given time interval due to slowness or program text.", "Failed"); Assert.Fail("'Add Template' window has not been closed after the given time interval due to slowness or program text."); //Purpose: Handling Template Program To Get Ready #region WaitForProgramToGetReady bool isAddTemplateWindowPresent = GenericHelper.IsPopUpWindowPresent("Add Template"); if (isAddTemplateWindowPresent) { GenericHelper.SelectWindow("Add Template"); bool isErrMsgPresent = GenericHelper.IsElementPresent(By.Id("lblErrMsg")); if (isErrMsgPresent) { string templateErrMsg = WebDriver.FindElement(By.Id("lblErrMsg")).Text; if (templateErrMsg.Contains("Program is not yet")) { GenericHelper.Logs("'Program is not yet ready. Please try again on few minutes.' text is displayed", "Passed"); Stopwatch sw = new Stopwatch(); sw.Start(); int minutesToWait = Int32.Parse(ConfigurationManager.AppSettings["AssignedToCopyInterval"]); while (sw.Elapsed.TotalMinutes < minutesToWait) { Thread.Sleep(10000); if (!GenericHelper.IsElementPresent((By.Id("lblErrMsg")))) { break; } string templateProgramErrMsg = WebDriver.FindElement(By.Id("lblErrMsg")).Text; if ( !templateProgramErrMsg.Contains("Program is not yet")) { GenericHelper.Logs("'Program is not yet ready. Please try again on few minutes' is validated aready for creation .", "PASSED"); break; } else { WebDriver.Close(); GenericHelper.SelectWindow("Manage Organization"); WebDriver.SwitchTo().Frame("frm"); GenericHelper.WaitUntilElement(By.XPath("//IMG[@class='tdAddImg']")); WebDriver.FindElement(By.XPath("//IMG[@class='tdAddImg']")).Click(); if (!WebDriver.FindElement(By.XPath("//TR[@id='trTemplate']")).Displayed) { WebDriver.FindElement(By.XPath("//IMG[@class='tdAddImg']")).Click(); } WebDriver.FindElement(By.XPath("//TR[@id='trTemplate']")).Click(); WebDriver.SwitchTo().ActiveElement(); GenericHelper.SelectWindow("Add Template"); GenericHelper.WaitUntilElement(By.Id("txtTempname")); templateName = GenericHelper.GenerateUniqueVariable("Template"); WebDriver.FindElement(By.Id("txtTempname")).SendKeys(templateName); WebDriver.FindElement(By.Id("txtTempDesc")).SendKeys(GenericHelper.GenerateUniqueVariable("DescriptionTemplate")); GetCcNameandMatch(); WebDriver.FindElement(By.Id("imgbtnAddTemplate")).Click(); } } if (GenericHelper.IsPopUpWindowPresent("Add Template")) { GenericHelper.Logs("Program is not yet ready for template creation in specified interval of time .", "FAILED"); Assert.Fail(string.Format("Program is not yet ready for template creation in specified interval of {0} time ", sw.Elapsed.TotalMinutes)); } sw.Stop(); sw = null; } else { GenericHelper.Logs("Program is not yet ready for template creation in specified interval of time.", "FAILED"); Assert.Fail("Program is not yet ready for template creation in specified interval of time."); } } else { GenericHelper.Logs("'.", "FAILED"); Assert.Fail("'Add Template' pop-up window has not been closed successfully."); } } #endregion WaitForProgramToGetReady else { GenericHelper.Logs("'Add Template' window has been closed successfully.", "PASSED"); } } } catch (Exception e) { GenericHelper.Logs(e.ToString(), "FAILED"); bool isAddTemplate = GenericHelper.IsPopUpWindowPresent("Add Template"); if (isAddTemplate) { GenericHelper.SelectWindow("Add Template"); WebDriver.Close(); } throw new Exception(e.ToString()); } }
// purpose - To Create SMSuser public void ToCreateSmsUser(string userType) { try { GenericHelper.SelectWindow("Access Information"); Assert.AreEqual("Access Information", WebDriver.Title); GenericHelper.WaitUntilElement((By.Id("accountNo"))); if (!WebDriver.FindElement(By.Id("accountNo")).Selected) { WebDriver.FindElement(By.Id("accountNo")).Click(); } GenericHelper.WaitUntilElement((By.Id("new_smsuser_loginname"))); WebDriver.FindElement(By.Id("new_smsuser_loginname")).Clear(); if (userType.Equals("CsSmsInstructor")) { smsUserName = GenericHelper.GenerateUniqueVariable("smsins"); } if (userType.Equals("CsSmsStudent")) { smsUserName = GenericHelper.GenerateUniqueVariable("smsstu"); } WebDriver.FindElement(By.Id("new_smsuser_loginname")).SendKeys(smsUserName); GenericHelper.WaitUntilElement((By.Id("createLoginPassword"))); WebDriver.FindElement(By.Id("createLoginPassword")).Clear(); WebDriver.FindElement(By.Id("createLoginPassword")).SendKeys("password1"); GenericHelper.WaitUntilElement((By.Id("createLoginPasswordRetype"))); WebDriver.FindElement(By.Id("createLoginPasswordRetype")).Clear(); WebDriver.FindElement(By.Id("createLoginPasswordRetype")).SendKeys("password1"); GenericHelper.WaitUntilElement(By.PartialLinkText("Switch to a single box for pasting your access code")); WebDriver.FindElement(By.PartialLinkText("Switch to a single box for pasting your access code")).Click(); WebDriver.SwitchTo().ActiveElement(); GenericHelper.SelectWindow("Access Information"); GenericHelper.WaitUntilElement((By.Id("access1"))); WebDriver.FindElement(By.Id("access1")).Clear(); switch (userType) { case "CsSmsInstructor": WebDriver.FindElement(By.Id("access1")).SendKeys("PGCIEN-CAPT-SOME-GALA-THOU-FROM"); break; case "CsSmsStudent": WebDriver.FindElement(By.Id("access1")).SendKeys("PGCISN-MALL-SOME-GALA-DASH-KAKI"); break; } GenericHelper.WaitUntilElement((By.Id("next"))); WebDriver.FindElement(By.Id("next")).Click(); GenericHelper.SelectWindow("Account Information"); Assert.AreEqual("Account Information", WebDriver.Title); GenericHelper.WaitUntilElement(By.Id("firstName")); WebDriver.FindElement(By.Id("firstName")).Clear(); WebDriver.FindElement(By.Id("firstName")).SendKeys(smsUserName); GenericHelper.WaitUntilElement(By.Id("lastName")); WebDriver.FindElement(By.Id("lastName")).Clear(); WebDriver.FindElement(By.Id("lastName")).SendKeys(smsUserName); GenericHelper.WaitUntilElement(By.Id("emailAddy")); WebDriver.FindElement(By.Id("emailAddy")).Clear(); WebDriver.FindElement(By.Id("emailAddy")).SendKeys("*****@*****.**"); GenericHelper.WaitUntilElement(By.Id("emailAddyConfirm")); WebDriver.FindElement(By.Id("emailAddyConfirm")).Clear(); WebDriver.FindElement(By.Id("emailAddyConfirm")).SendKeys("*****@*****.**"); GenericHelper.WaitUntilElement(By.Id("entered_countryid")); new SelectElement(WebDriver.FindElement(By.Id("entered_countryid"))).SelectByText("India"); GenericHelper.WaitUntilElement(By.Id("otherSchoolName")); WebDriver.FindElement(By.Id("otherSchoolName")).SendKeys("PegasusSchool"); GenericHelper.WaitUntilElement(By.Id("otherSchoolCity")); WebDriver.FindElement(By.Id("otherSchoolCity")).SendKeys("NewDelhi"); GenericHelper.WaitUntilElement(By.Name("person_verifyquestionid")); new SelectElement(WebDriver.FindElement(By.Name("person_verifyquestionid"))).SelectByText("What town was I born in?"); GenericHelper.WaitUntilElement(By.Id("password3")); WebDriver.FindElement(By.Id("password3")).Clear(); WebDriver.FindElement(By.Id("password3")).SendKeys("NewDelhi"); GenericHelper.WaitUntilElement(By.Id("next")); WebDriver.FindElement(By.Id("next")).Click(); GenericHelper.WaitUtilWindow("Confirmation and Summary"); bool isConfirmationWindowPresent = GenericHelper.IsWindowPresent("Confirmation and Summary"); if (isConfirmationWindowPresent) { GenericHelper.SelectWindow("Confirmation and Summary"); Assert.AreEqual("Confirmation and Summary", WebDriver.Title); if (GenericHelper.IsElementPresent(By.CssSelector("img.logInNow"))) { #region Selecting SMS User Type switch (userType) { case "CsSmsInstructor": DatabaseTools.UpdateUserDb(Enumerations.UserType.CsSmsInstructor, smsUserName, "password1", "*****@*****.**", 13, true); GenericHelper.Logs(string.Format("SMS User has been successfully created with {0}", smsUserName), "Passed"); break; case "CsSmsStudent": DatabaseTools.UpdateUserDb(Enumerations.UserType.CsSmsStudent, smsUserName, "password1", "*****@*****.**", 14, true); GenericHelper.Logs(string.Format("SMS User has been successfully created with {0}", smsUserName), "Passed"); break; } #endregion Selecting SMS User Type } } else { GenericHelper.Logs(string.Format("SMS User has not created with {0}", smsUserName), "Failed"); Assert.Fail("SMS User has not created with {0}", smsUserName); } } catch (Exception e) { GenericHelper.Logs(e.ToString(), "failed"); Assert.Fail(string.Format("Exception of type {0} cau" + "ght: {1}", e.GetType(), e.Message)); } }
// Purpose - Method To Create a Class Using Template public void ToCreateClass() { try { int tableNo = 1; Thread.Sleep(3000); WebDriver.WindowHandles.Any(item => WebDriver.SwitchTo().Window(item).Title == "Create Class"); WebDriver.SwitchTo().Frame("iframeCreateClass"); Classname = GenericHelper.GenerateUniqueVariable("ClassTemp"); GenericHelper.WaitUntilElement(By.Id("clsClassInformation_txtNewClassName")); WebDriver.FindElement(By.Id("clsClassInformation_txtNewClassName")).SendKeys(Classname); WebDriver.SwitchTo().DefaultContent(); GenericHelper.WaitUntilElement(By.Id("btnNext")); WebDriver.FindElement(By.Id("btnNext")).Click(); WebDriver.SwitchTo().Frame("iframeCreateClass"); GenericHelper.WaitUntilElement(By.Id("clsClassInformation_rdbChooseOrganisation")); if (!WebDriver.FindElement(By.Id("clsClassInformation_rdbChooseOrganisation")).Selected) { GenericHelper.Logs("Class creation option by using template is disabled", "FAILED"); throw new Exception("Class creation option by using template is disabled"); } WebDriver.FindElement(By.Id("clsClassInformation_rdbChooseOrganisation")).Click(); WebDriver.SwitchTo().DefaultContent(); GenericHelper.WaitUntilElement(By.Id("btnNext")); WebDriver.FindElement(By.Id("btnNext")).Click(); WebDriver.SwitchTo().Frame("iframeCreateClass"); string className = WebDriver.FindElement(By.XPath("//div[@id='clsClassContentList_pnlcontrolListContentType1']/table[" + tableNo + "]")).Text.Trim(); string templateName = DatabaseTools.GetTemplate(); if (templateName == null) { throw new ArgumentNullException(string.Format("Template Name {0} is null", null)); } if (className == templateName) { GenericHelper.WaitUntilElement(By.XPath("//div[@id='clsClassContentList_pnlcontrolListContentType1']/table[" + tableNo + "]/tbody/tr/td/input[@id='selectRadio']")); WebDriver.FindElement(By.XPath("//div[@id='clsClassContentList_pnlcontrolListContentType1']/table[" + tableNo + "]/tbody/tr/td/input[@id='selectRadio']")).Click(); } while (className != templateName) { tableNo = tableNo + 1; className = WebDriver.FindElement(By.XPath("//div[@id='clsClassContentList_pnlcontrolListContentType1']/table[" + tableNo + "]")).Text.Trim(); if (className == templateName) { GenericHelper.WaitUntilElement(By.XPath("//div[@id='clsClassContentList_pnlcontrolListContentType1']/table[" + tableNo + "]/tbody/tr/td/input[@id='selectRadio']")); WebDriver.FindElement(By.XPath("//div[@id='clsClassContentList_pnlcontrolListContentType1']/table[" + tableNo + "]/tbody/tr/td/input[@id='selectRadio']")).Click(); } } WebDriver.SwitchTo().DefaultContent(); GenericHelper.WaitUntilElement(By.Id("btnNext")); WebDriver.FindElement(By.Id("btnNext")).Click(); bool isThinkingIndicator = GenericHelper.ThinkingIndicatorProcessing(); if (isThinkingIndicator) { GenericHelper.Logs("Thinking indicator has stopped loading", "Passed"); } else { GenericHelper.Logs("Thinking indicator is still showing on the screen", "Failed"); throw new Exception("Thinking indicator is still showing on the screen"); } Thread.Sleep(10000); // This Thread I have added to avoid HTTP connection break! GenericHelper.WaitUntilElement(By.Id("btnNext")); WebDriver.FindElement(By.Id("btnNext")).Click(); GenericHelper.WaitUntilElement(By.Id("btnFinish")); WebDriver.FindElement(By.Id("btnFinish")).Click(); DatabaseTools.UpdateClass(Enumerations.ClassType.NovaNETTemplate, Classname); //Purpose: Verifying Create Class Window Closed Successfully bool isCreateClassWindowClosed = GenericHelper.IsPopUpClosed(3); if (isCreateClassWindowClosed) { GenericHelper.Logs("Create Class' window has been closed successfully.", "PASSED"); } else { GenericHelper.Logs("Create Class' window has not been closed successfully.", "FAILED"); throw new Exception("Create Class' window has not been closed successfully."); } } catch (Exception e) { GenericHelper.Logs(e.ToString(), "FAILED"); bool isCreateClassWindowPresent = GenericHelper.IsPopUpWindowPresent("Create Class"); if (isCreateClassWindowPresent) { GenericHelper.SelectWindow("Create Class"); WebDriver.Close(); } throw new Exception(e.ToString()); } }
/// <summary> /// Purpose: Add New Section /// </summary> public string AddNewSection() { string sectionName = GenericHelper.GenerateUniqueVariable("Section"); try { GenericHelper.SelectWindow("Program Administration"); WebDriver.SwitchTo().Frame("_ctl0_PageContent_ifrmMiddle"); GenericHelper.WaitUntilElement(By.XPath("//IMG[@class='CursorHand']")); WebDriver.FindElement(By.XPath("//IMG[@class='CursorHand']")).Click(); GenericHelper.SelectWindow("Create New Section"); GenericHelper.WaitUntilElement(By.Id("txtCourseName")); WebDriver.FindElement(By.Id("txtCourseName")).SendKeys(sectionName); GenericHelper.WaitUntilElement(By.Id("templatelist")); new SelectElement(WebDriver.FindElement(By.Id("templatelist"))).SelectByIndex(1); GenericHelper.WaitUntilElement(By.Id("noslist")); WebDriver.FindElement(By.Id("noslist")).SendKeys("1"); string startDate = DateTime.Now.ToString("MM/dd/yyyy"); string endDate = DateTime.Now.AddDays(90).ToString("MM/dd/yyyy"); GenericHelper.WaitUntilElement(By.Id("txtStartDate")); WebDriver.FindElement(By.Id("txtStartDate")).SendKeys(startDate); GenericHelper.WaitUntilElement(By.Id("txtEndDate")); WebDriver.FindElement(By.Id("txtEndDate")).SendKeys(endDate); GenericHelper.WaitUntilElement(By.Id("btnAddClose")); WebDriver.FindElement(By.Id("btnAddClose")).Click(); GenericHelper.SelectWindow("Program Administration"); GenericHelper.VerifySuccesfullMessage("Section added successfully."); WebDriver.SwitchTo().Frame("_ctl0_PageContent_ifrmMiddle"); GenericHelper.WaitUntilElement(By.XPath("//div[@id='grdTemplateSection$divContent']/table/tbody/tr/td/table/tbody/tr/td[2]")); Stopwatch sw = new Stopwatch(); sw.Start(); int minutesToWait = Int32.Parse(ConfigurationManager.AppSettings["AssignedToCopyInterval"]); while (sw.Elapsed.Minutes < minutesToWait) { IWebElement assignedToCopyText = WebDriver.FindElement(By.XPath("//div[@id='grdTemplateSection$divContent']/table/tbody/tr/td/table/tbody")); if (assignedToCopyText.Text.Contains("[Request is Processing") == false) { break; } { WebDriver.SwitchTo().DefaultContent(); GenericHelper.SelectWindow("Program Administration"); WebDriver.SwitchTo().Frame("_ctl0_PageContent_ifrmMiddle"); Thread.Sleep(6000); GenericHelper.WaitUntilElement(By.PartialLinkText("Search")); WebDriver.FindElement(By.PartialLinkText("Search")).Click(); WebDriver.SwitchTo().ActiveElement(); GenericHelper.WaitUntilElement(By.Id("txtSectionDetail")); WebDriver.FindElement(By.Id("txtSectionDetail")).Clear(); WebDriver.FindElement(By.Id("txtSectionDetail")).SendKeys(sectionName); GenericHelper.WaitUntilElement(By.Id("lnkbuttonsearch")); WebDriver.FindElement(By.Id("lnkbuttonsearch")).Click(); Thread.Sleep(8000); WebDriver.SwitchTo().DefaultContent(); GenericHelper.SelectWindow("Program Administration"); GenericHelper.WaitUntilElement(By.Id("_ctl0_PageContent_ifrmMiddle")); WebDriver.SwitchTo().Frame("_ctl0_PageContent_ifrmMiddle"); GenericHelper.WaitUntilElement(By.XPath("//div[@id='grdTemplateSection$divContent']/table/tbody/tr/td/table/tbody/tr/td[2]")); } } sw.Stop(); sw = null; IWebElement redTextPresent = WebDriver.FindElement(By.XPath("//div[@id='grdTemplateSection$divContent']/table/tbody/tr/td/table/tbody/tr/td[2]")); if (redTextPresent.Text.Contains("[Request is Processing")) { GenericHelper.Logs(string.Format("[Request is Processing state has not validated under:'{0}' minutes for copying section", minutesToWait), "FAILED"); WebDriver.Close(); Assert.Fail(string.Format("[Request is Processing state has not validated under:'{0}' minutes for copying section", minutesToWait)); } else { GenericHelper.Logs("Section active state validated successfully in prescribed interval of time.", "PASSED"); } } catch (Exception e) { GenericHelper.Logs(e.ToString(), "FAILED"); Assert.Fail(e.ToString()); } return(sectionName); }
public void CreateHedProduct(Enumerations.ProductInstance productType) { try { string productName = GenericHelper.GenerateUniqueVariable("BDD_Prod"); string programName = DatabaseTools.GetProgram(Enumerations.ProgramInstance.HedCore); GenericHelper.SelectWindow("Create New Product"); GenericHelper.WaitUntilElement(By.Id("txtProgramName")); WebDriver.FindElement(By.Id("txtProgramName")).SendKeys(productName); WebDriver.FindElement(By.Id("ancRightSearch")).Click(); GenericHelper.WaitUntilElement(By.Id("ifrmSearchProgram")); WebDriver.SwitchTo().Frame("ifrmSearchProgram"); GenericHelper.WaitUntilElement(By.Id("txtProgramName")); WebDriver.FindElement(By.Id("txtProgramName")).SendKeys(programName); WebDriver.FindElement(By.Id("btnSearch")).Click(); GenericHelper.WaitUntilElement(By.Id("grdPegasusDataGrid")); #region Browser Selection if (Browser.Equals("FF")) { if (WebDriver.FindElement(By.Id("grdPegasusDataGrid")).Text.Contains(programName)) { GenericHelper.Logs("Searched Program Found in 'Create New Product' page.", "PASSED"); } else { GenericHelper.Logs("Searched Program not Found in 'Create New Product' page.", "FAILED"); Assert.Fail("Searched Program not Found in 'Create New Product' page."); } } if (Browser.Equals("IE")) { if ( (WebDriver.FindElement(By.Id("grdPegasusDataGrid")).GetAttribute("innerText")).Contains( programName)) { GenericHelper.Logs("Searched Program Found in 'Create New Product' page.", "PASSED"); } else { GenericHelper.Logs("Searched Program not Found in 'Create New Product' page.", "FAILED"); Assert.Fail("Searched Program not Found in 'Create New Product' page."); } } #endregion Browser Selection GenericHelper.WaitUntilElement(By.Id("grdPegasusDataGrid$_ctrl1")); if (!WebDriver.FindElement(By.Id("grdPegasusDataGrid$_ctrl1")).Selected) { WebDriver.FindElement(By.Id("grdPegasusDataGrid$_ctrl1")).Click(); } WebDriver.SwitchTo().DefaultContent(); GenericHelper.WaitUntilElement(By.Id("txtSMSID")); WebDriver.FindElement(By.Id("txtSMSID")).SendKeys("2731"); if (productType.Equals(Enumerations.ProductInstance.HedCoreProgram)) { GenericHelper.WaitUntilElement(By.Id("chkIsProgram")); WebDriver.FindElement(By.Id("chkIsProgram")).Click(); GenericHelper.WaitUntilElement(By.Id("drpDiscipline")); WebDriver.FindElement(By.Id("drpDiscipline")).SendKeys(""); new SelectElement(WebDriver.FindElement(By.Id("drpDiscipline"))).SelectByText("Art"); GenericHelper.WaitUntilElement(By.Id("imgbtnSave")); WebDriver.FindElement(By.Id("imgbtnSave")).Click(); bool isCreateNewProductPopUpClosed = GenericHelper.IsPopUpClosed(2); if (isCreateNewProductPopUpClosed) { GenericHelper.Logs("'Create New Product' pop up window closed successfully after creation of product.", "PASSED"); DatabaseTools.UpdateProduct(productName, programName, Enumerations.ProductInstance.HedCoreProgram); } else { GenericHelper.Logs("'Create New Product' pop up window not closed successfully after creation of product.", "FAILED"); Assert.Fail("'Create New Product' pop up window not closed successfully after creation of product."); } } else { GenericHelper.WaitUntilElement(By.Id("imgbtnSave")); WebDriver.FindElement(By.Id("imgbtnSave")).Click(); bool isCreateNewProductPopUpClosed = GenericHelper.IsPopUpClosed(2); if (isCreateNewProductPopUpClosed) { GenericHelper.Logs("'Create New Product' pop up window closed successfully after creation of product.", "PASSED"); DatabaseTools.UpdateProduct(productName, programName, Enumerations.ProductInstance.HedCoreGeneral); } else { GenericHelper.Logs("'Create New Product' pop up window not closed successfully after creation of product.", "FAILED"); Assert.Fail("'Create New Product' pop up window not closed successfully after creation of product."); } } } catch (Exception e) { GenericHelper.Logs(e.ToString(), "FAILED"); if (GenericHelper.IsPopUpWindowPresent("Create New Product")) { GenericHelper.SelectWindow("Create New Product"); WebDriver.Close(); } Assert.Fail(string.Format("Exception of type {0} caught: {1}", e.GetType(), e.Message)); } }
//Pupose: To Create Product NovaNet public void CreateProduct() { try { string productName = GenericHelper.GenerateUniqueVariable("BDD_Prod"); string programName = DatabaseTools.GetProgram(Enumerations.ProgramInstance.NovaNET); GenericHelper.SelectWindow("Create New Product"); GenericHelper.WaitUntilElement(By.Id("txtProductName")); WebDriver.FindElement(By.Id("txtProductName")).SendKeys(productName); WebDriver.FindElement(By.Id("ancRightSearch")).Click(); GenericHelper.WaitUntilElement(By.Id("ifrmSearchProgram")); WebDriver.SwitchTo().Frame("ifrmSearchProgram"); GenericHelper.WaitUntilElement(By.Id("txtProgramName")); WebDriver.FindElement(By.Id("txtProgramName")).SendKeys(programName); WebDriver.FindElement(By.Id("btnSearch")).Click(); GenericHelper.WaitUntilElement(By.Id("grdPegasusDataGrid")); #region Browser Selection if (Browser.Equals("FF")) { if (WebDriver.FindElement(By.Id("grdPegasusDataGrid")).Text.Contains(programName)) { GenericHelper.Logs("Searched Program Found in 'Create New Product' page.", "PASSED"); } else { GenericHelper.Logs("Searched Program not Found in 'Create New Product' page.", "FAILED"); throw new Exception("Searched Program not Found in 'Create New Product' page."); } } if (Browser.Equals("IE")) { if ( (WebDriver.FindElement(By.Id("grdPegasusDataGrid")).GetAttribute("innerText")).Contains( programName)) { GenericHelper.Logs("Searched Program Found in 'Create New Product' page.", "PASSED"); } else { GenericHelper.Logs("Searched Program not Found in 'Create New Product' page.", "FAILED"); throw new Exception("Searched Program not Found in 'Create New Product' page."); } } #endregion Browser Selection WebDriver.FindElement(By.Id("grdPegasusDataGrid$_ctrl1")).Click(); GenericHelper.SelectWindow("Create New Product"); GenericHelper.WaitUntilElement(By.Id("drpProductType")); Actions builder = new Actions(WebDriver); IWebElement novenetDropDown = WebDriver.FindElement(By.Id("drpProductType")); builder.MoveToElement(novenetDropDown).Build().Perform(); if (Browser.Equals("IE")) { WebDriver.FindElement(By.Id("drpProductType")).SendKeys("NovaNet"); } if (Browser.Equals("FF") || Browser.Equals("GC")) { WebDriver.FindElement(By.Id("drpProductType")).FindElement(By.CssSelector("option[value='1']")). Click(); } IWebElement saveButton = WebDriver.FindElement(By.Id("imgbtnSave")); builder.MoveToElement(saveButton).Build().Perform(); GenericHelper.WaitUntilElement(By.Id("imgbtnSave")); WebDriver.FindElement(By.Id("imgbtnSave")).Click(); bool isCreateNewProductPopUpClosed = GenericHelper.IsPopUpClosed(2); if (isCreateNewProductPopUpClosed) { GenericHelper.Logs("'Create New Product' pop up window closed successfully after creation of product.", "PASSED"); DatabaseTools.UpdateProduct(productName, programName, Enumerations.ProductInstance.NovaNET); } else { GenericHelper.Logs("'Create New Product' pop up window not closed successfully after creation of product.", "FAILED"); throw new Exception("'Create New Product' pop up window not closed successfully after creation of product."); } } catch (Exception e) { GenericHelper.Logs(e.ToString(), "FAILED"); if (GenericHelper.IsPopUpWindowPresent("Create New Product")) { GenericHelper.SelectWindow("Create New Product"); WebDriver.Close(); } throw new Exception(e.ToString()); } }