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.EducationCenterPage.GcepLnk))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == GcepLnk.GetAttribute("outerHTML"))
                {
                    GcepLnk.SendKeys(Keys.Tab);  // Have to tab here, because in firefox, the menu item doesnt expand when we use the Selenium Click method. We first have to tab to expand
                    GcepLnk.Click();
                    Browser.WaitForElement(Bys.AMAPage.LoadIcon, TimeSpan.FromSeconds(120), ElementCriteria.IsNotVisible);
                    GCEPPage GP = new GCEPPage(Browser);
                    GP.WaitForInitialize();
                    return(GP);
                    // new WebDriverWait(Browser, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.UrlContains("gme-competency/admin"));
                    //new WebDriverWait(Browser, TimeSpan.FromSeconds(360)).Until(ExpectedConditions.InvisibilityOfElementLocated(Bys.AMAPage.LoadIcon));
                    // Browser.SwitchTo().Frame(G.EnterACPDFrame);
                }
            }
            if (Browser.Exists(Bys.EducationCenterPage.TranscriptLnk))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == TranscriptLnk.GetAttribute("outerHTML"))
                {
                    TranscriptLnk.Click();
                    return(new EducationCenterTransciptPage(Browser));
                    // Browser.WaitForElement(Bys.AMAPage.LoadIcon, ElementCriteria.IsNotVisible);
                    // Browser.SwitchTo().Frame(G.EnterACPDFrame);
                    // new WebDriverWait(Browser, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.UrlContains("gme-competency/admin"));
                }
            }
            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);
        }
Example #2
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.GCEPPage.UserManageLnk))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == UserManageLnk.GetAttribute("outerHTML"))
                {
                    UserManageLnk.Click();
                    GCEPUserMngPage GPU = new GCEPUserMngPage(Browser);
                    GPU.WaitForInitialize();
                    return(GPU);
                }
            }
            if (Browser.Exists(Bys.GCEPPage.CurriculumTemplatesLnk))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == CurriculumTemplatesLnk.GetAttribute("outerHTML"))
                {
                    WaitForInitialize();
                    CurriculumTemplatesLnk.Click();
                    CurriculumMngPage CMP = new CurriculumMngPage(Browser);
                    CMP.WaitForInitialize();
                    return(CMP);
                    //new WebDriverWait(Browser, TimeSpan.FromSeconds(25)).Until(ExpectedConditions.UrlContains("gme-competency/admin/programcurriculumtemplates"));
                }
            }
            if (Browser.Exists(Bys.GCEPPage.LibraryLnk))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == LibraryLnk.GetAttribute("outerHTML"))
                {
                    Browser.WaitForElement(Bys.AMAPage.LoadIcon, ElementCriteria.IsNotVisible);
                    LibraryLnk.Click();
                    GCEPLibraryPage GPL = new GCEPLibraryPage(Browser);
                    GPL.WaitForInitialize();
                    return(GPL);
                    // return  new CurriculumMngPage(Browser);
                }
            }
            if (Browser.Exists(Bys.GCEPPage.TranscriptLnk))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == TranscriptLnk.GetAttribute("outerHTML"))
                {
                    Browser.WaitForElement(Bys.AMAPage.LoadIcon, TimeSpan.FromSeconds(90), ElementCriteria.IsNotVisible);
                    TranscriptLnk.Click();
                    GCEPTranscriptPage GCTP = new GCEPTranscriptPage(Browser);
                    GCTP.WaitForInitialize();
                    return(GCTP);
                }
            }
            if (Browser.Exists(Bys.GCEPPage.InstitutionManagLnk))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == InstitutionManagLnk.GetAttribute("outerHTML"))
                {
                    WaitForInitialize();
                    InstitutionManagLnk.Click();
                    InstitutionsPage IP = new InstitutionsPage(Browser);
                    IP.WaitForInitialize();
                    return(IP);
                }
            }
            if (Browser.Exists(Bys.GCEPPage.DashboardNotificationManageLnk))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == DashboardNotificationManageLnk.GetAttribute("outerHTML"))
                {
                    WaitForInitialize();
                    DashboardNotificationManageLnk.Click();
                    DashboardNotificationsPage DNP = new DashboardNotificationsPage(Browser);
                    DNP.WaitForInitialize();
                    return(DNP);
                }
            }
            if (Browser.Exists(Bys.AMAPage.SignOutLnk))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == SignOutLnk.GetAttribute("outerHTML"))
                {
                    Browser.WaitForElement(Bys.AMAPage.LoadIcon, ElementCriteria.IsNotVisible);
                    HeaderMenuDropDown.Click();
                    SignOutLnk.SendKeys(Keys.Tab);
                    SignOutLnk.Click();
                    Thread.Sleep(0500);
                    return(this.Browser);
                    // new WebDriverWait(Browser, TimeSpan.FromSeconds(45)).Until(ExpectedConditions.UrlMatches("https://logintest.ama-assn.org/account/logout"));
                }
            }
            if (Browser.Exists(Bys.GCEPPage.PromotePGYLnk))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == PromotePGYLnk.GetAttribute("outerHTML"))
                {
                    WaitForInitialize();
                    PromotePGYLnk.Click();
                    Browser.WaitForElement(Bys.PromotePGYPage.AvailableResidentsPromotePGYTblFirstRowChk, ElementCriteria.IsVisible, ElementCriteria.IsEnabled);
                    PromotePGYPage PPGYP = new PromotePGYPage(Browser);
                    PPGYP.WaitForInitialize();
                    return(PPGYP);
                }
            }
            if (Browser.Exists(Bys.AMAPage.HelpLnk))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == HelpLnk.GetAttribute("outerHTML"))
                {
                    Browser.WaitForElement(Bys.AMAPage.LoadIcon, ElementCriteria.IsNotVisible);
                    HelpLnk.SendKeys(Keys.Tab);
                    HelpLnk.Click();
                    HelpPage HP = new HelpPage(Browser);
                    HP.WaitForInitialize();
                    return(HP);
                }
            }
            if (Browser.Exists(Bys.AMAPage.HelpfromYourInstitutionLnk))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == HelpfromYourInstitutionLnk.GetAttribute("outerHTML"))
                {
                    HeaderMenuDropDown.Click();
                    Thread.Sleep(0500);
                    HelpfromYourInstitutionLnk.Click();
                    Browser.SwitchTo().Window(Browser.WindowHandles.Last());
                    Thread.Sleep(0500);
                    Browser.Manage().Window.Maximize();
                    Thread.Sleep(0500);
                    Browser.SwitchTo().Window(Browser.WindowHandles.First()).Close();
                    if (Browser.WindowHandles.Count > 1)
                    {
                        Browser.SwitchTo().Window(Browser.WindowHandles.First()).Close();
                    }
                    Thread.Sleep(0500);
                    Browser.SwitchTo().Window(Browser.WindowHandles.Last());
                    Browser.Manage().Window.Maximize();
                    Thread.Sleep(0500);
                    HelpPage HP = new HelpPage(Browser);
                    HP.WaitForInitialize();
                    return(HP);
                }
            }
            if (Browser.Exists(Bys.GCEPPage.ResidentCouseStartNowBtn))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == ResidentCouseStartNowBtn.GetAttribute("outerHTML"))
                {
                    Browser.WaitForElement(Bys.AMAPage.LoadIcon, ElementCriteria.IsNotVisible);
                    ResidentCouseStartNowBtn.Click();
                    CourseTestPage CTP = new CourseTestPage(Browser);
                    CTP.WaitForInitialize();
                    return(CTP);
                }
            }
            if (Browser.Exists(Bys.GCEPPage.MemberBenefitsManagementLnk))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == MemberBenefitsManagementLnk.GetAttribute("outerHTML"))
                {
                    Browser.WaitForElement(Bys.AMAPage.LoadIcon, ElementCriteria.IsNotVisible);
                    MemberBenefitsManagementLnk.Click();
                    MemberBenefitPage MBP = new MemberBenefitPage(Browser);
                    MBP.WaitForInitialize();
                    return(MBP);
                }
            }
            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);
        }