Example #1
0
        /// <summary>
        /// Clicks the user-specified button or link and then waits for a window to close or open, or a page to load,
        /// depending on the button that was clicked
        /// </summary>
        /// <param name="buttonOrLinkElem">The element to click on</param>
        public dynamic ClickToAdvance(IWebElement buttonOrLinkElem)
        {
            if (Browser.Exists(Bys.GCEPLibraryPage.SearchBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == SearchBtn.GetAttribute("outerHTML"))
                {
                    SearchBtn.Click();
                    // Browser.WaitForElement(Bys.EducationCenterPage.MyCoursesTtl, TimeSpan.FromSeconds(60), ElementCriteria.IsVisible, ElementCriteria.IsEnabled);
                    //Browser.WaitForElement(Bys.EducationCenterPage.GcepLnk, TimeSpan.FromSeconds(60), ElementCriteria.IsEnabled);
                    new WebDriverWait(Browser, TimeSpan.FromSeconds(15)).Until(ExpectedConditions.UrlContains("Courses.aspx"));

                    return(new EducationCenterPage(Browser));
                    // }
                }
            }
            if (Browser.Exists(Bys.GCEPLibraryPage.BeginCourseBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == BeginCourseBtn.GetAttribute("outerHTML"))
                {
                    BeginCourseBtn.Click();
                    return(new CourseTestPage(Browser));
                }
            }

            if (Browser.Exists(Bys.GCEPLibraryPage.TranscriptLnk))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == TranscriptLnk.GetAttribute("outerHTML"))
                {
                    TranscriptLnk.Click();
                    Browser.WaitForElement(Bys.GCEPTranscriptPage.CompletedTestTbl, TimeSpan.FromSeconds(60), ElementCriteria.IsVisible, ElementCriteria.IsEnabled);

                    return(new GCEPTranscriptPage(Browser));
                }
            }
            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);
        }