Exemple #1
0
        /// <summary>
        /// Enters text in the username and password field, clicks the login button, then waits for the URL
        /// of the home page to load
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        public dynamic Login(IWebDriver browser, string userName, string password)
        {
            browser.Navigate().GoToUrl(string.Format("{0}login", System.Configuration.ConfigurationManager.AppSettings["LSURL"].ToString()));
            LoginPage LSLP = new LoginPage(browser);

            LSLP.WaitForInitialize();

            UserNameTxt.Clear();
            PasswordTxt.Clear();
            UserNameTxt.SendKeys(userName);
            PasswordTxt.SendKeys(password);
            PasswordTxt.SendKeys(Keys.Tab);
            ClickAndWait(LoginBtn);

            // If there is only 1 site in an environment, then the application will go to that sites landing page. If there are multiple sites,
            // then it goes to the Search page. So we first need to wait for an element that appears on BOTH pages (The Sites breadcrumb link)
            Browser.WaitForElement(Bys.SitePage.SitesBreadCrumbLnk, ElementCriteria.IsVisible);

            // Then use a TRY to wait a split second for the Sites page Additional Information tab (This tab appears immediately along
            // with the Sites breadcrumb link). If that doesnt appear, then that means we will be on the Search page, so
            // we will use the Catch to wait for the Search page
            try
            {
                Browser.WaitForElement(Bys.SitePage.AdditionalInfoTab, TimeSpan.FromMilliseconds(500), ElementCriteria.IsVisible);
                SitePage page = new SitePage(Browser);
                return(page);
            }
            catch
            {
                SearchPage page = new SearchPage(Browser);
                page.WaitForInitialize();
                return(page);
            }
        }
Exemple #2
0
        /// <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.Page.AllParticipantsLnk))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == AllParticipantsLnk.GetAttribute("outerHTML"))
                {
                    buttonOrLinkElem.Click();
                    SearchPage page = new SearchPage(Browser);
                    page.WaitUntilAll(Criteria.SearchPage.AllParticpantsTblBodyNotLoading, Criteria.SearchPage.SearchTxtVisible);
                    return(page);
                }
            }

            if (Browser.Exists(Bys.Page.SitesTab))
            {
                if (buttonOrLinkElem.GetAttribute("outerHTML") == SitesTab.GetAttribute("outerHTML"))
                {
                    buttonOrLinkElem.Click();
                    Thread.Sleep(0200);

                    // If there is only 1 site in an environment, then the application will go to that sites landing page. If there are multiple sites,
                    // then it goes to the Search page. So we first need to wait for an element that appears on BOTH pages (The Sites breadcrumb link)
                    Browser.WaitForElement(Bys.SitePage.SitesBreadCrumbLnk, ElementCriteria.IsVisible);

                    // Then use a TRY to wait a split second for the Sites page Additional Information tab (This tab appears immediately along
                    // with the Sites breadcrumb link). If that doesnt appear, then that means we will be on the Search page, so
                    // we will use the Catch to wait for the Search page
                    try
                    {
                        Browser.WaitForElement(Bys.SitePage.AdditionalInfoTab, TimeSpan.FromMilliseconds(500), ElementCriteria.IsVisible);
                        SitePage page = new SitePage(Browser);
                        page.WaitForInitialize();
                        return(page);
                    }
                    catch
                    {
                        SearchPage page = new SearchPage(Browser);
                        page.WaitForInitialize();
                        Thread.Sleep(0400);
                        return(page);
                    }
                }
            }

            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);
        }