/// <summary> /// Clicks the user-specified button, link, tab, etc. 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.CBDProgDeanPage.LearnersTab)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == LearnersTab.GetAttribute("outerHTML")) { LearnersTab.Click(); this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDProgDeanPage.LearnersTblBodyRowVisibleAndEnabled); this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDProgDeanPage.LoadElementDoneLoading); return; } } if (Browser.Exists(Bys.RCPPage.CBDTab)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == Browser.FindElement(Bys.RCPPage.CBDTab).GetAttribute("outerHTML")) { buttonOrLinkElem.Click(); this.WaitUntil(TimeSpan.FromSeconds(180), Criteria.CBDProgDeanPage.PageReady); return; } } if (Browser.Exists(Bys.CBDProgDeanPage.AddRemoveFlagFormRemoveFlagBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == AddRemoveFlagFormRemoveFlagBtn.GetAttribute("outerHTML")) { AddRemoveFlagFormRemoveFlagBtn.Click(); this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDProgDeanPage.LearnersTblBodyRowVisibleAndEnabled); this.WaitUntil(Criteria.CBDProgDeanPage.LoadElementDoneLoading); return; } } if (Browser.Exists(Bys.CBDProgDeanPage.AddRemoveFlagFormSaveFlagBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == AddRemoveFlagFormSaveFlagBtn.GetAttribute("outerHTML")) { AddRemoveFlagFormSaveFlagBtn.Click(); this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDProgDeanPage.LearnersTblBodyRowVisibleAndEnabled); this.WaitUntil(Criteria.CBDProgDeanPage.LoadElementDoneLoading); return; } } if (Browser.Exists(Bys.CBDProgDeanPage.AddNotesFormSubmitBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == AddNotesFormSubmitBtn.GetAttribute("outerHTML")) { AddNotesFormSubmitBtn.Click(); this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDProgDeanPage.LearnersTblBodyRowVisibleAndEnabled); this.WaitUntil(Criteria.CBDProgDeanPage.LoadElementDoneLoading); return; } } if (Browser.Exists(Bys.RCPPage.LogoutLnk)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == LogoutLnk.GetAttribute("outerHTML")) { ElemSet.ScrollToElement(Browser, LogoutLnk); LogoutLnk.Click(); new WebDriverWait(Browser, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.UrlContains("login")); return; } } if (Browser.Exists(Bys.CBDProgDeanPage.AddSupportingDocumentationFormSubmitBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == AddSupportingDocumentationFormSubmitBtn.GetAttribute("outerHTML")) { AddSupportingDocumentationFormSubmitBtn.Click(); this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDProgDeanPage.LearnersTblBodyRowVisibleAndEnabled); this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDProgDeanPage.LoadElementDoneLoading); 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."); } }
/// <summary> /// Clicks the user-specified element that exists on every page of RCP, 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 element to click on</param> public dynamic ClickAndWaitBasePage(IWebElement buttonOrLinkElem) { // Error handler to make sure that the button that the tester passed in the parameter is actually on the page if (Browser.Exists(Bys.RCPPage.PERAFCTab)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == PERAFCTab.GetAttribute("outerHTML")) { // Using javascript based click because firefox doesnt click on these tabs using Selenium based click. Might be a current geckodriver bug. Revisit JavascriptUtils.Click(Browser, buttonOrLinkElem); PERCredentialStaffPage page = new PERCredentialStaffPage(Browser); page.WaitForInitialize(); return(page); } } if (Browser.Exists(Bys.RCPPage.MyDiplomaTab)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == MyDiplomaTab.GetAttribute("outerHTML")) { // Using javascript based click because firefox doesnt click on these tabs using Selenium based click. Might be a current geckodriver bug. Revisit JavascriptUtils.Click(Browser, buttonOrLinkElem); DiplomaCredentialStaffPage page = new DiplomaCredentialStaffPage(Browser); page.WaitForInitialize(); return(page); } } if (Browser.Exists(Bys.RCPPage.MyDashboardTab)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == MyDashboardTab.GetAttribute("outerHTML")) { // Using javascript based click because firefox doesnt click on these tabs using Selenium based click. Might be a current geckodriver bug. Revisit JavascriptUtils.Click(Browser, buttonOrLinkElem); MyDashboardPage page = new MyDashboardPage(Browser); page.WaitForInitialize(); return(page); } } if (Browser.Exists(Bys.RCPPage.MyCPDActivitiesTab)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == MyCPDActivitiesTab.GetAttribute("outerHTML")) { // Using javascript based click because firefox doesnt click on these tabs using Selenium based click. Might be a current geckodriver bug. Revisit JavascriptUtils.Click(Browser, buttonOrLinkElem); MyCPDActivitiesListPage page = new MyCPDActivitiesListPage(Browser); page.WaitForInitialize(); return(page); } } if (Browser.Exists(Bys.RCPPage.MyMOCTab)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == MyMOCTab.GetAttribute("outerHTML")) { // Using javascript based click because firefox doesnt click on these tabs using Selenium based click. Might be a current geckodriver bug. Revisit JavascriptUtils.Click(Browser, buttonOrLinkElem); MyMOCPage page = new MyMOCPage(Browser); page.WaitForInitialize(); return(page); } } if (Browser.Exists(Bys.RCPPage.MyHoldingAreaTab)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == MyHoldingAreaTab.GetAttribute("outerHTML")) { // Using javascript based click because firefox doesnt click on these tabs using Selenium based click. Might be a current geckodriver bug. Revisit JavascriptUtils.Click(Browser, buttonOrLinkElem); MyHoldingAreaPage page = new MyHoldingAreaPage(Browser); page.WaitForInitialize(); return(page); } } if (Browser.Exists(Bys.RCPPage.CBDTab)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == CBDTab.GetAttribute("outerHTML")) { // Using javascript based click because firefox doesnt click on these tabs using Selenium based click. Might be a current geckodriver bug. Revisit JavascriptUtils.Click(Browser, buttonOrLinkElem); // We dont want wait criteria here, because clicking this tab can be on any role within RCP, so there can be many things to wait for return(null); } } if (Browser.Exists(Bys.RCPPage.LogoutLnk)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == LogoutLnk.GetAttribute("outerHTML")) { LogoutLnk.Click(); this.WaitForElement(Bys.RCPPage.LoginLnk, ElementCriteria.IsVisible); return(null); } } 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."); } return(null); }
/// <summary> /// Clicks the user-specified button, link, tab, etc. 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.CBDProgDirectorPage.AddRemoveFlagFormRemoveFlagBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == AddRemoveFlagFormRemoveFlagBtn.GetAttribute("outerHTML")) { AddRemoveFlagFormRemoveFlagBtn.Click(); this.WaitUntilAll(TimeSpan.FromSeconds(60), Criteria.CBDProgDirectorPage.LearnersTblRowBodyVisibleAndEnabled, Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide, Criteria.CBDProgDirectorPage.LoadElementDisappeared); return; } } if (Browser.Exists(Bys.RCPPage.CBDTab)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == Browser.FindElement(Bys.RCPPage.CBDTab).GetAttribute("outerHTML")) { buttonOrLinkElem.Click(); this.WaitUntil(TimeSpan.FromSeconds(180), Criteria.CBDProgDirectorPage.PageReady); return; } } if (Browser.Exists(Bys.CBDProgDirectorPage.AddRemoveFlagFormSaveFlagBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == AddRemoveFlagFormSaveFlagBtn.GetAttribute("outerHTML")) { AddRemoveFlagFormSaveFlagBtn.Click(); this.WaitUntilAll(TimeSpan.FromSeconds(60), Criteria.CBDProgDirectorPage.LearnersTblRowBodyVisibleAndEnabled, Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide, Criteria.CBDProgDirectorPage.LoadElementDisappeared); return; } } if (Browser.Exists(Bys.CBDProgDirectorPage.SchedProgMeetFormScheduleBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == SchedProgMeetFormScheduleBtn.GetAttribute("outerHTML")) { SchedProgMeetFormScheduleBtn.Click(); this.WaitUntilAll(TimeSpan.FromSeconds(60), Criteria.CBDProgDirectorPage.LearnersTblRowBodyVisibleAndEnabled, Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide, Criteria.CBDProgDirectorPage.LoadElementDisappeared); this.WaitForInitialize(); return; } } if (Browser.Exists(Bys.CBDProgDirectorPage.AddNotesFormSubmitBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == AddNotesFormSubmitBtn.GetAttribute("outerHTML")) { AddNotesFormSubmitBtn.Click(); this.WaitUntilAll(TimeSpan.FromSeconds(60), Criteria.CBDProgDirectorPage.LearnersTblRowBodyVisibleAndEnabled, Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide, Criteria.CBDProgDirectorPage.LoadElementDisappeared); this.WaitForInitialize(); return; } } if (Browser.Exists(Bys.CBDProgDirectorPage.AssignObsFormNextBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == AssignObsFormNextBtn.GetAttribute("outerHTML")) { AssignObsFormNextBtn.Click(); Browser.WaitForElement(Bys.CBDProgDirectorPage.AssignObsFormBackBtn, ElementCriteria.IsEnabled); Browser.WaitForElement(Bys.CBDProgDirectorPage.AssignObsFormBackBtn, ElementCriteria.IsVisible); Browser.WaitForElement(Bys.CBDProgDirectorPage.AssignObsFormBackBtn, ElementCriteria.HasText); this.WaitForInitialize(); return; } } if (Browser.Exists(Bys.CBDProgDirectorPage.AssignObsFormSearchBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == AssignObsFormSearchBtn.GetAttribute("outerHTML")) { AssignObsFormSearchBtn.Click(); Browser.WaitForElement(Bys.CBDProgDirectorPage.AssignObsFormObserverNameTxt, ElementCriteria.IsEnabled); this.WaitForInitialize(); Thread.Sleep(1000); this.WaitForInitialize(); return; } } if (Browser.Exists(Bys.CBDProgDirectorPage.AssignObsFormAssignBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == AssignObsFormAssignBtn.GetAttribute("outerHTML")) { AssignObsFormAssignBtn.Click(); this.WaitForInitialize(); return; } } if (Browser.Exists(Bys.CBDProgDirectorPage.CompCommiteeTab)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == CompCommiteeTab.GetAttribute("outerHTML")) { CompCommiteeTab.Click(); // Note that the if this is a new environment, then this will fail because the Agenda table will not have any rows. You have to log in manually and create // an agenda so that the agenda table gets rows this.WaitUntilAll(TimeSpan.FromSeconds(60), Criteria.CBDProgDirectorPage.AgendaTblRowBodyVisibleAndEnabled, Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide, Criteria.CBDProgDirectorPage.LoadElementDisappeared); return; } } if (Browser.Exists(Bys.CBDProgDirectorPage.CreateNewAgendaLnk)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == CreateNewAgendaLnk.GetAttribute("outerHTML")) { CreateNewAgendaLnk.Click(); this.WaitUntilAll(TimeSpan.FromSeconds(120), Criteria.CBDProgDirectorPage.CreateNewAgendaFormProgramSelElemHasItemsAndIsEnabled, Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide, Criteria.CBDProgDirectorPage.LoadElementDisappeared); return; } } if (Browser.Exists(Bys.CBDProgDirectorPage.CreateNewAgendaFormCreateBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == CreateNewAgendaFormCreateBtn.GetAttribute("outerHTML")) { CreateNewAgendaFormCreateBtn.Click(); this.WaitUntilAll(TimeSpan.FromSeconds(120), Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide, Criteria.CBDProgDirectorPage.LoadElementDisappeared); // This failed once and the screenshot showed that the load element was still there. So the above wait criteria didnt work, // maybe there is a second load icon that appears. So lets condition this so that if the form did not close yet, then wait // again for the load icon to disappear. if (Browser.FindElements(Bys.CBDProgDirectorPage.CreateNewAgendaFormCreateBtn).Count > 0) { this.WaitUntilAll(TimeSpan.FromSeconds(120), Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide, Criteria.CBDProgDirectorPage.LoadElementDisappeared); } return; } } if (Browser.Exists(Bys.CBDProgDirectorPage.SetStatusFormConfirmBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == SetStatusFormConfirmBtn.GetAttribute("outerHTML")) { SetStatusFormConfirmBtn.Click(); this.WaitUntilAll(TimeSpan.FromSeconds(60), Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide, Criteria.CBDProgDirectorPage.LoadElementDisappeared); return; } } if (Browser.Exists(Bys.CBDProgDirectorPage.FinalizeAgendaBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == FinalizeAgendaBtn.GetAttribute("outerHTML")) { FinalizeAgendaBtn.Click(); this.WaitUntilAll(TimeSpan.FromSeconds(60), Criteria.CBDProgDirectorPage.FinalizeAgendaFormFinalizeBtnIsEnabled, Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide, Criteria.CBDProgDirectorPage.LoadElementDisappeared); return; } } if (Browser.Exists(Bys.CBDProgDirectorPage.FinalizeAgendaFormFinalizeBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == FinalizeAgendaFormFinalizeBtn.GetAttribute("outerHTML")) { FinalizeAgendaFormFinalizeBtn.Click(); this.WaitUntilAll(TimeSpan.FromSeconds(60), Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide, Criteria.CBDProgDirectorPage.LoadElementDisappeared, Criteria.CBDProgDirectorPage.AgendaTblRowBodyVisibleAndEnabled); return; } } if (Browser.Exists(Bys.RCPPage.LogoutLnk)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == LogoutLnk.GetAttribute("outerHTML")) { ElemSet.ScrollToElement(Browser, LogoutLnk); LogoutLnk.Click(); new WebDriverWait(Browser, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.UrlContains("login")); return; } } if (Browser.Exists(Bys.CBDProgDirectorPage.AddSupportingDocumentationFormSubmitBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == AddSupportingDocumentationFormSubmitBtn.GetAttribute("outerHTML")) { AddSupportingDocumentationFormSubmitBtn.Click(); this.WaitUntilAll(Criteria.CBDProgDirectorPage.LearnersTblRowBodyVisibleAndEnabled, Criteria.CBDProgDirectorPage.LoadElementClassAttributeSetToHide, Criteria.CBDProgDirectorPage.LoadElementDisappeared); 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."); } }
/// <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) { // Error handler to make sure that the button that the tester passed in the parameter is actually on the page if (Browser.Exists(Bys.CBDLearnerPage.BackBtn)) { // This is a workaround to be able to use an IF statement on an IWebElement type. if (buttonOrLinkElem.GetAttribute("outerHTML") == BackBtn.GetAttribute("outerHTML")) { BackBtn.Click(); this.WaitForInitialize(); return; } } if (Browser.Exists(Bys.RCPPage.CBDTab)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == CBDTab.GetAttribute("outerHTML")) { buttonOrLinkElem.Click(); this.WaitUntil(TimeSpan.FromSeconds(180), Criteria.CBDLearnerPage.PageReadyWithProgramLearningTabReady); return; } } if (Browser.Exists(Bys.CBDLearnerPage.AddReflectBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == AddReflectBtn.GetAttribute("outerHTML")) { // NOTE: This sometimes does not work in Firefox whenever the tooltip for one of the tabs appears. Firefox // fails to click when a tooltip is covering the button. However, this started working today. If it stops // working again, we will have to implement a workaround in the SwitchTabs method AddReflectBtn.Click(); WaitUtils.WaitForPopup(Browser, TimeSpan.FromSeconds(30), Bys.CBDLearnerPage.AddReflectFormContinueBtn); //Browser.WaitForElement(Bys.CBDLearnerPage.AddReflectFormContinueBtn, ElementCriteria.IsVisible, ElementCriteria.IsEnabled); this.WaitUntil(TimeSpan.FromSeconds(360), Criteria.CBDLearnerPage.LoadElementDoneLoading); return; } } if (Browser.Exists(Bys.CBDLearnerPage.AddReflectFormContinueBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == AddReflectFormContinueBtn.GetAttribute("outerHTML")) { AddReflectFormContinueBtn.Click(); WaitUtils.WaitForPopup(Browser, TimeSpan.FromSeconds(30), Bys.CBDLearnerPage.AddReflectFormBrowseBtn); this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.LoadElementDoneLoading); //Browser.WaitForElement(Bys.CBDLearnerPage.AddReflectFormBrowseBtn, ElementCriteria.IsVisible); return; } } if (Browser.Exists(Bys.CBDLearnerPage.AddReflectFormSubmitBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == AddReflectFormSubmitBtn.GetAttribute("outerHTML")) { AddReflectFormSubmitBtn.Click(); this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.PageReadyWithReflectionsTabReady); return; } } if (Browser.Exists(Bys.CBDLearnerPage.RequestObservationBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == RequestObservationBtn.GetAttribute("outerHTML")) { RequestObservationBtn.Click(); WaitUtils.WaitForPopup(Browser, TimeSpan.FromSeconds(30), Bys.CBDLearnerPage.RequestObsFormObsNameTxt); this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.LoadElementDoneLoading); //Browser.WaitForElement(Bys.CBDLearnerPage.RequestObsFormObsNameTxt, ElementCriteria.IsVisible, ElementCriteria.IsEnabled); //Browser.WaitForElement(Bys.CBDLearnerPage.RequestObsFormSearchBtn, ElementCriteria.IsVisible, ElementCriteria.IsEnabled); // Need to revisit the above 2 lines. For some reason, this needs a tiny static wait to work sometimes //Thread.Sleep(0600); return; } } if (Browser.Exists(Bys.CBDLearnerPage.RequestObsFormSearchBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == RequestObsFormSearchBtn.GetAttribute("outerHTML")) { // 11/30/17: It failed today. Said "Failed to find any elements By.XPath: //tbody[@aria-label='Select Observer']" // I looked on the screenshot and the radio button never got returned, even though the label beneath it said // "Showing 1-1 of 1". This tells me that this is an application bug. Hopefully this fixes itself when DEV works // on performance improvements. If not, and I see this again, I might have to add some more logic below to keep // clicking or something else // 11/05/17: For some reason, selenium sometimes fails to click this button. So I am adding a Catch and using javascript based click event if this fails try { RequestObsFormSearchBtn.Click(); this.WaitUntilAll(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.RequestObsFormRdoBtnTbodyVisible, Criteria.CBDLearnerPage.RequestObsFormFirstRdoVisible); this.WaitUntilAll(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.LoadElementDoneLoading); // Adding a Sleep here for now until I have time to come back and add some dynamic wait criteria Thread.Sleep(0300); } catch { ((IJavaScriptExecutor)Browser).ExecuteScript("arguments[0].click()", RequestObsFormSearchBtn); this.WaitForElement(Bys.CBDLearnerPage.RequestObsFormRdoBtnTbody, TimeSpan.FromSeconds(60), ElementCriteria.IsVisible); this.WaitUntilAll(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.LoadElementDoneLoading); // Adding a Sleep here for now until I have time to come back and add some dynamic wait criteria Thread.Sleep(0300); } return; } } if (Browser.Exists(Bys.CBDLearnerPage.RequestObsFormRequestBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == RequestObsFormRequestBtn.GetAttribute("outerHTML")) { RequestObsFormRequestBtn.Click(); this.WaitForElement(Bys.CBDLearnerPage.RequestObsFormOkBtn, ElementCriteria.IsVisible); this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.LoadElementDoneLoading); return; } } if (Browser.Exists(Bys.CBDLearnerPage.RequestObsFormOkBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == RequestObsFormOkBtn.GetAttribute("outerHTML")) { RequestObsFormOkBtn.Click(); this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.LoadElementDoneLoading); return; } } if (Browser.Exists(Bys.RCPPage.LogoutLnk)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == LogoutLnk.GetAttribute("outerHTML")) { ElemSet.ScrollToElement(Browser, LogoutLnk); LogoutLnk.Click(); new WebDriverWait(Browser, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.UrlContains("login")); return; } } if (Browser.Exists(Bys.CBDLearnerPage.AddReflectFormContinueBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == AddReflectFormContinueBtn.GetAttribute("outerHTML")) { AddReflectFormContinueBtn.Click(); WaitUtils.WaitForPopup(Browser, TimeSpan.FromSeconds(30), Bys.CBDLearnerPage.AddReflectFormBrowseBtn); this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.LoadElementDoneLoading); return; } } if (Browser.Exists(Bys.CBDLearnerPage.ViewMoreRptsLnk)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == ViewMoreRptsLnk.GetAttribute("outerHTML")) { ViewMoreRptsLnk.Click(); WaitUtils.WaitForPopup(Browser, TimeSpan.FromSeconds(30), Bys.CBDLearnerPage.ReportsFormShowBtn); this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.LoadElementDoneLoading); return; } } if (Browser.Exists(Bys.CBDLearnerPage.ReportsFormShowBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == ReportsFormShowBtn.GetAttribute("outerHTML")) { ReportsFormShowBtn.Click(); Browser.WaitForElement(Bys.CBDLearnerPage.ReportsFormEPAObservCntChrt, ElementCriteria.IsVisible, ElementCriteria.IsEnabled, ElementCriteria.HasText); return; } } if (Browser.Exists(Bys.CBDLearnerPage.ReportsFormCloseBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == ReportsFormCloseBtn.GetAttribute("outerHTML")) { ReportsFormCloseBtn.Click(); this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.PageReadyWithProgramLearningTabReady); 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."); } }
/// <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."); } }