Exemplo n.º 1
0
        /// <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.PERCredentialStaffPage.RefereesTab))
            {
                // This is a workaround to be able to use an IF statement on an IWebElement type.
                if (buttonOrLinkElem.GetAttribute("outerHTML") == RefereesTab.GetAttribute("outerHTML"))
                {
                    buttonOrLinkElem.Click();
                    this.WaitUntilAll(Criteria.PERCredentialStaffPage.RefereesTabTraineeTblFirstRowVisible);
                    return;
                }
            }

            if (Browser.Exists(Bys.PERCredentialStaffPage.AssignAssessor3rdAssFormSubmitBtn, ElementCriteria.IsVisible))
            {
                // This is a workaround to be able to use an IF statement on an IWebElement type.
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AssignAssessor3rdAssFormSubmitBtn.GetAttribute("outerHTML"))
                {
                    buttonOrLinkElem.Click();
                    this.WaitUntilAny(Criteria.PERCredentialStaffPage.AssignAssessor3rdAssFormThirdAssSelElemNotVisible,
                                      Criteria.PERCredentialStaffPage.BackGroundBackDropNotExists);
                }

                return;
            }

            if (Browser.Exists(Bys.PERCredentialStaffPage.AssessorTab))
            {
                // This is a workaround to be able to use an IF statement on an IWebElement type.
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AssessorTab.GetAttribute("outerHTML"))
                {
                    buttonOrLinkElem.Click();
                    this.WaitUntilAll(Criteria.PERCredentialStaffPage.AssessorTabTraineeTblFirstRowVisible);
                    return;
                }
            }

            if (Browser.Exists(Bys.PERCredentialStaffPage.AssignReferee2PERRefsFormSubmitBtn, ElementCriteria.IsVisible))
            {
                // This is a workaround to be able to use an IF statement on an IWebElement type.
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AssignReferee2PERRefsFormSubmitBtn.GetAttribute("outerHTML"))
                {
                    buttonOrLinkElem.Click();
                    this.WaitUntilAll(Criteria.PERCredentialStaffPage.AssignReferee2PERRefsFormFirstRefSelElemNotVisible,
                                      Criteria.PERCredentialStaffPage.BackGroundBackDropNotExists);
                    return;
                }
            }

            if (Browser.Exists(Bys.PERCredentialStaffPage.AssignAssessor2AssFormSubmitBtn, ElementCriteria.IsVisible))
            {
                // This is a workaround to be able to use an IF statement on an IWebElement type.
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AssignAssessor2AssFormSubmitBtn.GetAttribute("outerHTML"))
                {
                    buttonOrLinkElem.Click();
                    this.WaitUntilAll(Criteria.PERCredentialStaffPage.AssignAssessor2AssFormFirstAssSelElemNotVisible,
                                      Criteria.PERCredentialStaffPage.BackGroundBackDropNotExists);
                    return;
                }
            }

            if (Browser.Exists(Bys.PERCredentialStaffPage.FinalReviewFormSubmitBtn))
            {
                // This is a workaround to be able to use an IF statement on an IWebElement type.
                if (buttonOrLinkElem.GetAttribute("outerHTML") == FinalReviewFormSubmitBtn.GetAttribute("outerHTML"))
                {
                    buttonOrLinkElem.Click();

                    if (Browser.Exists(Bys.PERCredentialStaffPage.AssignAssessor2AssFormFirstAssSelElem))
                    {
                        this.WaitUntilAll(Criteria.PERCredentialStaffPage.FinalReviewFormAchievedRdoNotVisible,
                                          Criteria.PERCredentialStaffPage.BackGroundBackDropNotExists);
                        Thread.Sleep(0500);
                        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 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.DiplomaCredentialStaffPage.PortfoliosUnderReviewTab))
            {
                // This is a workaround to be able to use an IF statement on an IWebElement type.
                if (buttonOrLinkElem.GetAttribute("outerHTML") == PortfoliosUnderReviewTab.GetAttribute("outerHTML"))
                {
                    buttonOrLinkElem.Click();
                    this.WaitUntilAll(Criteria.DiplomaCredentialStaffPage.PortfoliosUnderReviewTblFirstRowVisible);
                    Thread.Sleep(0400);
                    return;
                }
            }

            if (Browser.Exists(Bys.DiplomaCredentialStaffPage.RecordPaymentFormSubmitBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == RecordPaymentFormSubmitBtn.GetAttribute("outerHTML"))
                {
                    buttonOrLinkElem.Click();
                    this.WaitUntilAll(TimeSpan.FromSeconds(120), Criteria.DiplomaCredentialStaffPage.RecordPaymentFormSubmitBtnSubmitBtnNotVisible,
                                      Criteria.DiplomaCredentialStaffPage.BackGroundBackDropNotExists);
                    // After this backdrop element disappears, I think we need a very small sleep, because I once encountered a StaleElementException
                    // when trying to click something after this above wait, when not having a sleep. Monitor going forward
                    Thread.Sleep(0200);
                    return;
                }
            }

            if (Browser.Exists(Bys.DiplomaCredentialStaffPage.MarkPortfolioAsAchievedFormSubmitBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == MarkPortfolioAsAchievedFormSubmitBtn.GetAttribute("outerHTML"))
                {
                    buttonOrLinkElem.Click();
                    this.WaitUntilAll(Criteria.DiplomaCredentialStaffPage.AssignAssessor3rdAssFormSubmitBtnNotVisible,
                                      Criteria.DiplomaCredentialStaffPage.BackGroundBackDropNotExists);
                    // After this backdrop element disappears, I think we need a very small sleep, because I once encountered a StaleElementException
                    // when trying to click something after this above wait, when not having a sleep. Monitor going forward
                    Thread.Sleep(0200);
                    return;
                }
            }

            if (Browser.Exists(Bys.DiplomaCredentialStaffPage.AssignAssessor3rdAssFormSubmitBtn, ElementCriteria.IsVisible))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AssignAssessor3rdAssFormSubmitBtn.GetAttribute("outerHTML"))
                {
                    buttonOrLinkElem.Click();
                    this.WaitUntilAll(Criteria.DiplomaCredentialStaffPage.AssignAssessor3rdAssFormSubmitBtnNotVisible,
                                      Criteria.DiplomaCredentialStaffPage.BackGroundBackDropNotExists);
                    // After this backdrop element disappears, I think we need a very small sleep, because I once encountered a StaleElementException
                    // when trying to click something after this above wait, when not having a sleep. Monitor going forward
                    Thread.Sleep(0200);
                }

                return;
            }

            if (Browser.Exists(Bys.DiplomaCredentialStaffPage.AssessorTab))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AssessorTab.GetAttribute("outerHTML"))
                {
                    buttonOrLinkElem.Click();
                    this.WaitUntil(Criteria.DiplomaCredentialStaffPage.AssessorTblFirstRowVisible);
                    Thread.Sleep(0400);
                    return;
                }
            }

            if (Browser.Exists(Bys.DiplomaCredentialStaffPage.AssignAssessor2AssFormSubmitBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AssignAssessor2AssFormSubmitBtn.GetAttribute("outerHTML"))
                {
                    buttonOrLinkElem.Click();
                    this.WaitUntilAll(Criteria.DiplomaCredentialStaffPage.AssignAssessor2AssFormSubmitBtnNotVisible,
                                      Criteria.DiplomaCredentialStaffPage.BackGroundBackDropNotExists);
                    // After this backdrop element disappears, I think we need a very small sleep, because I once encountered a StaleElementException
                    // when trying to click something after this above wait, when not having a sleep. Monitor going forward
                    Thread.Sleep(0200);
                    return;
                }
            }

            if (Browser.Exists(Bys.DiplomaCredentialStaffPage.FinalReviewFormSubmitBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == FinalReviewFormSubmitBtn.GetAttribute("outerHTML"))
                {
                    buttonOrLinkElem.Click();
                    this.WaitUntilAll(Criteria.DiplomaCredentialStaffPage.FinalReviewFormAchievedRdoNotVisible,
                                      Criteria.DiplomaCredentialStaffPage.BackGroundBackDropNotExists);
                    // After this backdrop element disappears, I think we need a very small sleep, because I once encountered a StaleElementException
                    // when trying to click something after this above wait, when not having a sleep. Monitor going forward
                    Thread.Sleep(0200);
                    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.");
            }
        }