/// <summary> /// Fills the required fields on the AMA Self Learning Page /// </summary> /// public void FillOutAMAActivityForm1(int creditValue) { //generate the data to fill out the data DateTime dt = DateTime.Now; int currentDay = dt.Day; int currentMonth = dt.Month; int currentYear = dt.Year; int currentHour = dt.Hour; int currentMinute = dt.Minute; int currentSecond = dt.Second; //create a string for the program title String ProgramTitle = "TestRun_" + currentMonth + "_" + currentDay + "_" + currentYear + "-" + currentHour + ":" + currentMinute + ":" + currentSecond; //These lines fill out the //text fields in the AMA Self Learning Activity Form ProgramTitleAMASLTxt.SendKeys(ProgramTitle); ProvinceSelectorAMASLDrpDn.SelectByIndex(1); ProvinceSelectorAMASLDrpDn.SelectByText("Alberta (AB)"); CityAMASLTxt.SendKeys("Test City"); PlanningOrganizationAMASLTxt.SendKeys("Test"); string date = DateTime.Today.AddDays(-1).ToString("MM/dd/yyyy", CultureInfo.InvariantCulture); //Generate a date to use later in the form ElemSet.ScrollToElement(Browser, ActivityStartDateAMASLTxt); ActivityStartDateAMASLTxt.SendKeys(date); ActivityCompletionDateAMASLTxt.SendKeys(date); CreditsClaimedAMASLTxt.SendKeys("" + creditValue); //clicking on the radio buttons //at the end of the form ElemSet.ClickAfterScroll(Browser, ChangedImprovedAMASLRdo); ElemSet.ClickAfterScroll(Browser, LearnedNewAMASLRdo); ElemSet.ClickAfterScroll(Browser, LearnedMoreAMASLRdo); ElemSet.ClickAfterScroll(Browser, DissatisfiedAMASLRdo); ElemSet.ClickAfterScroll(Browser, BiasedAMASLRdo); ElemSet.ClickAfterScroll(Browser, ConfirmedAMASLRdo); // For some reason, whenever we use Selenium's built in click method here, it triggers the application to add more than // 1 credit for the activity/user (We entered "1" into the CreditsClaimed text box above, so only 1 credit should get // added for the user). I added a workaround to use the javascript version of a click, and this // works (only adds the specified amount of credits) For more info, // see https://stackoverflow.com/questions/24571048/selenium-webelement-click-vs-javascript-click-event JavascriptUtils.Click(Browser, SubmitButton); SubmitButton.SendKeys(Keys.Tab); Thread.Sleep(20000); // MIKE: Definitely add wait criteria here. I see that a popup appears, we can wait on an element in this popup }
/// <summary> /// Fills the required fields on the AMA Group Learning Page /// </summary> /// public void FillOutAMAActivityForm2() { //generate the data to fill out the data DateTime dt = DateTime.Now; int currentDay = dt.Day; int currentMonth = dt.Month; int currentYear = dt.Year; int currentHour = dt.Hour; int currentMinute = dt.Minute; int currentSecond = dt.Second; //create a string for the program title String ProgramTitle = "TestRun_" + currentMonth + "_" + currentDay + "_" + currentYear + "-" + currentHour + ":" + currentMinute + ":" + currentSecond; //These lines fill out the //text fields in the AMA Group Learning Activity Form ProgramTitleAMAGLTxt.SendKeys(ProgramTitle); ProvinceSelectorAMAGLDrpDn.SelectByIndex(1); ProvinceSelectorAMAGLDrpDn.SelectByText("Alberta (AB)"); CityAMAGLTxt.SendKeys("Test City"); PlanningOrganizationAMAGLTxt.SendKeys("Test"); string date = DateTime.Today.AddDays(-1).ToString("MM/dd/yyyy", CultureInfo.InvariantCulture); //generate a date value for the activity forms ElemSet.ScrollToElement(Browser, ActivityStartDateAMAGLTxt); ActivityStartDateAMAGLTxt.SendKeys(date); ActivityCompletionDateAMAGLTxt.SendKeys(date); CreditsClaimedAMAGLTxt.SendKeys("1"); //Select out the group radio buttons ElemSet.ClickAfterScroll(Browser, ChangedImprovedAMAGLRdo); ElemSet.ClickAfterScroll(Browser, LearnedNewAMAGLRdo); ElemSet.ClickAfterScroll(Browser, LearnedMoreAMAGLRdo); ElemSet.ClickAfterScroll(Browser, DissatisfiedAMAGLRdo); ElemSet.ClickAfterScroll(Browser, BiasedAMAGLRdo); ElemSet.ClickAfterScroll(Browser, ConfirmedAMAGLRdo); // MIKE: I would name these elements with a little more detail. It took me, a new person, a little bit of time to figure out what radio button was for each variable // MIKE: Always start with the beginning text when naming elements. For example for this radio button, name it "ThisExperienceConfirmedRdo" instead of just "Confirmed" // For some reason, whenever we use Selenium's built in click method here, it triggers the application to add more than // 1 credit for the activity/user (We entered "1" into the CreditsClaimed text box above, so only 1 credit should get // added for the user). I added a workaround to use the javascript version of a click, and this // works (only adds the specified amount of credits) For more info, // see https://stackoverflow.com/questions/24571048/selenium-webelement-click-vs-javascript-click-event JavascriptUtils.Click(Browser, SubmitButton); SubmitButton.SendKeys(Keys.Tab); }
/// <summary> /// Fills out the Self page /// </summary> /// public void FillOutSelfLearningForm() { //generate the data to fill out the data DateTime dt = DateTime.Now; int currentDay = dt.Day; int currentMonth = dt.Month; int currentYear = dt.Year; int currentHour = dt.Hour; int currentMinute = dt.Minute; int currentSecond = dt.Second; //create a string for the program title String ProgramTitle = "TestRun_" + currentMonth + "_" + currentDay + "_" + currentYear + "-" + currentHour + ":" + currentMinute + ":" + currentSecond; Thread.Sleep(3000);//add wait criteria later ElemSet.ScrollToElement(Browser, ProgramTitleCertifiedSelfLearningTxt); ProgramTitleCertifiedSelfLearningTxt.SendKeys(ProgramTitle); //move down to the province selection screen ElemSet.ScrollToElement(Browser, CityTxtCertifiedSelfLearningTxt); //select alberta ProvinceSelectorCertifiedSelfLearningDrpDn.SelectByIndex(1); //Fill out the test city CityTxtCertifiedSelfLearningTxt.SendKeys("Test City"); //fill out the PlanningOrganizationCertifiedSelfLearningTxt.SendKeys("Test"); //generate a date for these Activity Test DateTime dt2 = DateTime.Today.AddDays(-1); String startDateText = dt2.Month + "/" + dt2.Day + "/" + dt2.Year; String completionDateText = dt2.Month + "/" + dt2.Day + "/" + dt2.Year; ActivityStartDateCertifiedSelfLearningTxt.SendKeys(startDateText); ActivityCompletionDateCertifiedSelfLearningTxt.SendKeys(completionDateText); CreditsClaimedDateCertifiedSelfLearningTxt.SendKeys("1"); ElemSet.ClickAfterScroll(Browser, ChangedImprovedCertifiedGSelfLearningRdo); ElemSet.ClickAfterScroll(Browser, LearnedNewCertifiedSelfLearningRdo); ElemSet.ClickAfterScroll(Browser, LearnedMoreCertifiedSelfLearningRdo); ElemSet.ClickAfterScroll(Browser, ConfirmedCertifiedSelfLearningRdo); ElemSet.ClickAfterScroll(Browser, BiasedCertifiedSelfLearningRdo); ElemSet.ClickAfterScroll(Browser, DissatisfiedCertifiedSelfLearningRdo); ElemSet.ScrollToElement(Browser, SubmitButton); // For some reason, whenever we use Selenium's built in click method here, it triggers the application to add more than // 1 credit for the activity/user (We entered "1" into the CreditsClaimed text box above, so only 1 credit should get // added for the user). I added a workaround to use the javascript version of a click, and this // works (only adds the specified amount of credits) For more info, // see https://stackoverflow.com/questions/24571048/selenium-webelement-click-vs-javascript-click-event JavascriptUtils.Click(Browser, SubmitButton); SubmitButton.SendKeys(Keys.Tab); Thread.Sleep(20000); }
/// <summary> /// Fills the required fields on the enter a CPD activity page /// </summary> /// public void FillOutAssessmentForm() { //generate the data to fill out the data DateTime dt = DateTime.Now; int currentDay = dt.Day; int currentMonth = dt.Month; int currentYear = dt.Year; int currentHour = dt.Hour; int currentMinute = dt.Minute; int currentSecond = dt.Second; //create a string for the program title String ProgramTitle = "TestRun_" + currentMonth + "_" + currentDay + "_" + currentYear + "-" + currentHour + ":" + currentMinute + ":" + currentSecond; Thread.Sleep(2000); ProgramTitleCertifiedAssessmentTxt.SendKeys(ProgramTitle); //move down to the province selection screen IWebElement element = Browser.FindElement(By.Id("ctl00_ContentPlaceHolder1_CFPCActivitiesWizard_ctl03_fb1_ctl06_ctl17_CEComboBox3449685")); // Put this element in the page bys class ElemSet.ScrollToElement(Browser, element); // MIKE: Removed a bunch of end lines //select alberta ProvinceSelectorDrpDn.SelectByIndex(1); ProvinceSelectorDrpDn.SelectByText("Alberta (AB)"); // MIKE: I added this line and commented the one above it. Why use index when you know which item you are going to choose? The index might change in the future if more items are added to the select list //Fill out the test city CityTxt.SendKeys("Test City"); //fill out the PlanningOrganizationTxt.SendKeys("Test"); //generate a date for these Activity Test string date = DateTime.Today.AddDays(-1).ToString("MM/dd/yyyy", CultureInfo.InvariantCulture); // MIKE: I added this line and commented out the below lines. Reduces lines and having seperate varaibles for the start and end doesnt make sense in this case //DateTime dt2 = DateTime.Today.AddDays(-1); //String startDateText = dt2.Month + "/" + dt2.Day + "/" + dt2.Year; //String completionDateText = dt2.Month + "/" + dt2.Day + "/" + dt2.Year; //send the text to the box ActivityStartDateTxt.SendKeys(date); ActivityCompletionDateTxt.SendKeys(date); CreditsClaimedTxt.SendKeys("1"); ChangedImprovedRdo.Click(); LearnedNewRdo.Click(); LearnMoreRdo.Click(); //scroll to the dissatisfied radio button // ElemSet.ScrollToElement(Browser,DissatisfiedRdo); ElemSet.ClickAfterScroll(Browser, DissatisfiedRdo); // MIKE: I added this line and commented the above one. We can talk at meeting BiasedRdo.Click(); //scroll to element ElemSet.ClickAfterScroll(Browser, ConfirmedRdo); // MIKE: I would name these elements with a little more detail. It took me, a new person, a little bit of time to figure out what radio button was for each variable // MIKE: Always start with the beginning text when naming elements. For example for this radio button, name it "ThisExperienceConfirmedRdo" instead of just "Confirmed" // For some reason, whenever we use Selenium's built in click method here, it triggers the application to add more than // 1 credit for the activity/user (We entered "1" into the CreditsClaimed text box above, so only 1 credit should get // added for the user). I added a workaround to use the javascript version of a click, and this // works (only adds the specified amount of credits) For more info, // see https://stackoverflow.com/questions/24571048/selenium-webelement-click-vs-javascript-click-event JavascriptUtils.Click(Browser, SubmitButton); SubmitButton.SendKeys(Keys.Tab); Thread.Sleep(20000); // MIKE: Definitely add wait criteria here. I see that a popup appears, we can wait on an element in this popup }