/// <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 element to click on</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. I changed this to a Javascript and it worked so far. // Monitor going forwards and if the javascript click also fails, we will have to implement a workaround // in the SwitchTabs method // buttonOrLinkElem.Click(); JavascriptUtils.Click(Browser, buttonOrLinkElem); 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(0400); 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 // 1/25/18: Failed. The failure said that the Ok button (The button that is lcoated on the screen after clicking the Request button) // could not be found. Looked at screenshot, and it showed that the Search button did not get clicked (at least that is what I think, // because ALL observers showed inside the table), the Template (Part A) radio button DID get clicked, the Observer radio button // did NOT get clicked, so as a result, the Request button was disabled and could not be clicked. A video would really be helpful // to debug this, because I dont know why the observer table showed ALL observers (Did the search not get clicked even with the Try // Catch below? Did it actually get clicked, but the application failed to filter the observers (This would be an application bug)?) // Aside form those questions, the observer still showed in the table, but failed to get selected. I am adding a longer sleep here, // 5 milliseconds up from 3 milliseconds. Monitor going forward try { RequestObsFormSearchBtn.Click(); this.WaitUntilAll(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.RequestObsFormRdoBtnTbodyVisible, Criteria.CBDLearnerPage.RequestObsFormFirstRdoVisible); this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.LoadElementDoneLoading); Thread.Sleep(0500); } catch { ((IJavaScriptExecutor)Browser).ExecuteScript("arguments[0].click()", RequestObsFormSearchBtn); this.WaitUntilAll(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.RequestObsFormRdoBtnTbodyVisible, Criteria.CBDLearnerPage.RequestObsFormFirstRdoVisible); this.WaitUntil(TimeSpan.FromSeconds(120), Criteria.CBDLearnerPage.LoadElementDoneLoading); Thread.Sleep(0500); } 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.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) { // 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 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 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."); } }