/// <summary> /// Clicks the Actions button inside of a user-specified row, clicks the Accept/Decline button, fills the form and either /// clicks the Accept or Decline button /// </summary> /// <param name="learnerName">The first and last name of the learner with the pending observation request</param> /// <param name="acceptOrDecline">Either "Accept" "Decline"</param> /// <returns></returns> public AcceptDeclineAssignmentFormInfo AcceptOrDeclineAssignment(string learnerName, string formName, string acceptOrDecline) { IWebElement btn = ElemSet.Grid_ClickButtonOrLinkWithinRow(Browser, PendingAcceptanceTbl, Bys.CBDObserverPage.PendingAcceptanceTblRowBody, learnerName, "td", "Actions", "span", formName, "span"); Thread.Sleep(0500); IWebElement btnParent = XpathUtils.GetNthParentElem(btn, 3); ElemSet.Grid_ClickMenuItemInsideDropdown(Browser, btnParent, "Accept/Decline Assignment"); // Wait until the Accept/Decline assesment window opens Browser.WaitForElement(Bys.CBDObserverPage.AccDecAssgnMntFormCommentsTxt, TimeSpan.FromSeconds(60), ElementCriteria.IsVisible, ElementCriteria.IsEnabled); Browser.WaitForElement(Bys.RCPPage.LoadIcon, TimeSpan.FromSeconds(60), ElementCriteria.AttributeValue("class", "page-splash dissolve-animation ng-hide") .OR(ElementCriteria.AttributeValue("class", "page-splash dissolve-animation ng-animate ng-hide"))); AcceptDeclineAssignmentFormInfo ADFO = FillAcceptDeclineAssignmentForm(); if (acceptOrDecline == "Accept") { ClickAndWait(AccDecAssgnMntFormAcceptBtn); } else { // TOD: Add code for declining assessment ClickAndWait(AccDecAssgnMntFormDeclineBtn); ClickAndWait(ConfirmFormDeclineAssessYesBtn); } return(ADFO); }
/// <summary> /// Clicks on any tab within the main page (this does not include popups) of the Learner page /// </summary> /// <param name="tabElem">The tab element</param> /// <param name="by">The element as it exists in the By type. For examples, <see cref="Bys.CBDLearnerPage"/></param> public void SwitchToTab(IWebElement tabElem, By by) { Browser.WaitForElement(Bys.RCPPage.LoadIcon, TimeSpan.FromSeconds(3), ElementCriteria.AttributeValue("class", "page-splash dissolve-animation ng-hide") .OR(ElementCriteria.AttributeValue("class", "page-splash dissolve-animation ng-animate ng-hide"))); tabElem.Click(); this.WaitForElement(by, ElementCriteria.IsEnabled, ElementCriteria.IsVisible); this.WaitUntil(TimeSpan.FromSeconds(60), Criteria.CBDLearnerPage.GenericTableEnabled); }
/// <summary> /// For any table within LS, this method enters text in the search box, then either clicks Go or hits Enter and waits for table to /// get returned by waiting for the the tbody element's "class" attribute to not have a value of "loading" /// </summary> /// <param name="tblBody">The tbody element in your table</param> /// <param name="searchText">What you want to search for</param> public void Search(By tblBody, string searchText) { SearchTxt.SendKeys(searchText); SearchTxt.SendKeys(Keys.Enter); Thread.Sleep(0400); Browser.WaitForElement(tblBody, TimeSpan.FromSeconds(240), ElementCriteria.AttributeValueNot("class", "loading")); Thread.Sleep(1000); }
/// <summary> /// Clicks on the Competence Committee tab if that page is not in view, then creates an upcoming agenda with a random date. /// It opens the Create New Agenda window, assigns the date and clicks Create to create the new agenda. It will then pick this /// new agenda in the Meeting Agenda dropdown /// </summary> public void CreateUpcomingAgendaThenSelectIt() { string agendaToSelect = ""; // If we are not on the Competence Committee tab, then click on it to go there if (!Browser.Exists(Bys.CBDProgDirectorPage.FinalizeAgendaBtn, ElementCriteria.IsEnabled)) { ClickAndWait(CompCommiteeTab); } agendaToSelect = CreateUpcomingAgendaWithRandomDate(); ElemSet.SelElem_SelectItemContainingText(MeetingAgendaSelElem, agendaToSelect); Browser.WaitForElement(Bys.RCPPage.LoadIcon, TimeSpan.FromMinutes(3), ElementCriteria.AttributeValue("class", "page-splash dissolve-animation ng-hide") .OR(ElementCriteria.AttributeValue("class", "page-splash dissolve-animation ng-animate ng-hide"))); }
public static List <UoWCriteria> CriteriaOutputForm(CslaObjectInfo info, UnitOfWorkFunction function, bool generatingCriteria) { var result = new List <UoWCriteria>(); var propertyDeclarationCache = new Dictionary <string, PropertyDeclaration>(); foreach (var uowProperty in info.UnitOfWorkProperties) { propertyDeclarationCache[uowProperty.TypeName] = uowProperty.DeclarationMode; } var criteriaCollectionCounter = 0; foreach (var criteriaCollection in info.UnitOfWorkCriteriaObjects) { var creatorCounter = criteriaCollection.Count(crit => crit.IsCreator); if (function == UnitOfWorkFunction.Creator) { if (creatorCounter == 0) { continue; } } else if (function == UnitOfWorkFunction.Getter) { if (creatorCounter != 0) { continue; } } var uowCriteria = new UoWCriteria(); criteriaCollectionCounter++; foreach (var crit in criteriaCollection) { if (function == UnitOfWorkFunction.Creator && (!crit.IsCreator && (crit.IsGetter && CslaTemplateHelperCS.IsEditableType(crit.ParentObject.ObjectType)))) { break; } if (function == UnitOfWorkFunction.Getter && !crit.IsGetter) { break; } if (function == UnitOfWorkFunction.Deleter && !crit.IsDeleter) { break; } var elementCriteria = new ElementCriteria(); elementCriteria.ParentObject = crit.ParentObject.ObjectName; elementCriteria.DeclarationMode = propertyDeclarationCache[elementCriteria.ParentObject]; elementCriteria.IsGetter = !CslaTemplateHelperCS.IsEditableType(crit.ParentObject.ObjectType); if (crit.Properties.Count == 0) { uowCriteria.ElementCriteriaList.Add(elementCriteria); } else { elementCriteria.Name = crit.Name; elementCriteria.Namespace = GetElementCriteriaNamesapce(crit); elementCriteria.Type = crit.Name; if (crit.Properties.Count == 1) { elementCriteria.Name = crit.Properties[0].Name; elementCriteria.Type = CslaTemplateHelperCS.GetDataTypeGeneric(crit.Properties[0], crit.Properties[0].PropertyType); } if (generatingCriteria) { var newElementCriteria = new ElementCriteria(); foreach (var prop in crit.Properties.Where(prop => !string.IsNullOrEmpty(prop.UnitOfWorkFactoryParameter))) { newElementCriteria.ParentObject = elementCriteria.Parameter; newElementCriteria.DeclarationMode = elementCriteria.DeclarationMode; newElementCriteria.IsGetter = elementCriteria.IsGetter; newElementCriteria.Namespace = elementCriteria.Namespace; newElementCriteria.Type = "bool"; newElementCriteria.Name = "Create" + elementCriteria.ParentObject; } uowCriteria.ElementCriteriaList.Add(newElementCriteria); } else { foreach (var prop in crit.Properties.Where(prop => !string.IsNullOrEmpty(prop.UnitOfWorkFactoryParameter))) { if (!string.IsNullOrEmpty(elementCriteria.Parameter)) { elementCriteria.Parameter += ", "; } elementCriteria.Parameter += prop.UnitOfWorkFactoryParameter; } } uowCriteria.ElementCriteriaList.Add(elementCriteria); } } var elementCriteriaListCount = uowCriteria.ElementCriteriaList.Count(elementCriteria => !string.IsNullOrEmpty(elementCriteria.Name)); if ((generatingCriteria && elementCriteriaListCount > 1) || (!generatingCriteria && elementCriteriaListCount > 0)) { uowCriteria.CriteriaName = GetNumberedCriteria(info.UnitOfWorkCriteriaObjects.Count, criteriaCollectionCounter); } else { criteriaCollectionCounter--; } if (uowCriteria.ElementCriteriaList.Count > 0) { result.Add(uowCriteria); } } return(result); }
/// <summary> /// Clicks the user-specified element and then waits for a window to close or open, or a page to load, /// depending on the element that was clicked /// </summary> /// <param name="buttonOrLinkElem">The button element</param> public void ClickAndWait(IWebElement buttonOrLinkElem) { if (Browser.Exists(Bys.CBDObserverPage.AccDecAssgnMntFormAcceptBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == AccDecAssgnMntFormAcceptBtn.GetAttribute("outerHTML")) { AccDecAssgnMntFormAcceptBtn.Click(); this.WaitForInitialize(); // 9/18/17 Commented the following line. Im pretty sure this is not needed anymore, because I implemented this wait in the PageCriteria class Browser.WaitForElement(Bys.RCPPage.LoadIcon, TimeSpan.FromSeconds(60), ElementCriteria.AttributeValue("class", "page-splash dissolve-animation ng-hide") .OR(ElementCriteria.AttributeValue("class", "page-splash dissolve-animation ng-animate ng-hide"))); return; } } if (Browser.Exists(Bys.RCPPage.CBDTab)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == CBDTab.GetAttribute("outerHTML")) { buttonOrLinkElem.Click(); this.WaitUntil(Criteria.CBDObserverPage.PageReady); return; } } if (Browser.Exists(Bys.CBDObserverPage.AccDecAssgnMntFormDeclineBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == AccDecAssgnMntFormDeclineBtn.GetAttribute("outerHTML")) { AccDecAssgnMntFormDeclineBtn.Click(); Browser.WaitForElement(Bys.CBDObserverPage.ConfirmFormCompleteAssessYesBtn, ElementCriteria.IsEnabled); this.WaitForInitialize(); return; } } if (Browser.Exists(Bys.CBDObserverPage.ConfirmFormRemoveAssessOkBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == ConfirmFormRemoveAssessOkBtn.GetAttribute("outerHTML")) { ConfirmFormRemoveAssessOkBtn.Click(); this.WaitForInitialize(); return; } } if (Browser.Exists(Bys.CBDObserverPage.ConfirmFormDeclineAssessYesBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == ConfirmFormDeclineAssessYesBtn.GetAttribute("outerHTML")) { ConfirmFormDeclineAssessYesBtn.Click(); this.WaitForInitialize(); return; } } if (Browser.Exists(Bys.CBDObserverPage.CompleteAssessFormSubmitBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == CompleteAssessFormSubmitBtn.GetAttribute("outerHTML")) { CompleteAssessFormSubmitBtn.Click(); this.WaitForInitialize(); Browser.WaitForElement(Bys.CBDObserverPage.ConfirmFormCompleteAssessYesBtn, ElementCriteria.IsEnabled); return; } } if (Browser.Exists(Bys.CBDObserverPage.ConfirmFormCompleteAssessYesBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == ConfirmFormCompleteAssessYesBtn.GetAttribute("outerHTML")) { ConfirmFormCompleteAssessYesBtn.Click(); this.WaitForInitialize(); return; } } if (Browser.Exists(Bys.RCPPage.LogoutLnk)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == LogoutLnk.GetAttribute("outerHTML")) { LogoutLnk.Click(); new WebDriverWait(Browser, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.UrlContains("login")); return; } } if (Browser.Exists(Bys.CBDObserverPage.AddObservationBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == AddObservationBtn.GetAttribute("outerHTML")) { AddObservationBtn.Click(); WaitUtils.WaitForPopup(Browser, TimeSpan.FromSeconds(30), Bys.CBDObserverPage.AddObsFormSearchBtn); this.WaitForInitialize(); return; } } if (Browser.Exists(Bys.CBDObserverPage.AddObsFormSearchBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == AddObsFormSearchBtn.GetAttribute("outerHTML")) { AddObsFormSearchBtn.Click(); WaitUtils.WaitForPopup(Browser, TimeSpan.FromSeconds(30), Bys.CBDObserverPage.AddObsFormObsTblFacultyColHdr); this.WaitForInitialize(); Thread.Sleep(1000); return; } } if (Browser.Exists(Bys.CBDObserverPage.AddObsFormNextBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == AddObsFormNextBtn.GetAttribute("outerHTML")) { AddObsFormNextBtn.Click(); Browser.WaitForElement(Bys.CBDObserverPage.AddObsFormBackBtn, ElementCriteria.IsEnabled); Browser.WaitForElement(Bys.CBDObserverPage.AddObsFormBackBtn, ElementCriteria.IsVisible); Browser.WaitForElement(Bys.CBDObserverPage.AddObsFormBackBtn, ElementCriteria.HasText); this.WaitForInitialize(); return; } } else { throw new Exception("No button or link was found with your passed parameter. You either need to add this button to a new If statement, " + "or if the button is already added, then the page you were on did not contain the button."); } }