Exemple #1
0
        private void SelectBy(SelectionKind selectionKind, object selection, bool blur, bool waitForItself = false, bool waitForDynamicContentLoad = true)
        {
            if (waitForItself)
            {
                WaitForElementVisibleAndEnabled();
            }

            //Assert.IsTrue(Element.Displayed, string.Format("Element {0} is not Displayed", Locator));		//TODO
            //Assert.IsTrue(Element.Enabled, string.Format("Element {0} is not Enabled", Locator));			//TODO

            Selector[selectionKind](selection);

            if (waitForDynamicContentLoad)
            {
                ParentPage.WaitForDynamicContentToLoad();
            }

            if (blur)
            {
                Blur(true, false);
            }

            if (waitForDynamicContentLoad)
            {
                ParentPage.WaitForDynamicContentToLoad();
            }

            LogSelection(selectionKind, selection, blur);
        }
Exemple #2
0
        /// <summary>
        /// Also waits for dynamic contents to load (updater overlay to dissapear, pending ajax calls to finish) - due to some controls triggering overlay loader or ajax calls after being edited
        /// </summary>
        /// <param name="waitForItself"></param>
        /// <param name="waitForDynamicContentLoad"></param>
        public void Blur(bool waitForItself = true, bool waitForDynamicContentLoad = true)      //param waitForItself must be default true because stale test needs to happen when it's used directly on control
        {
            if (waitForItself)
            {
                WaitForElementVisibleAndEnabled();
            }

            Element.SendKeys("\t");             //Keys.Tab

            if (waitForDynamicContentLoad)
            {
                ParentPage.WaitForDynamicContentToLoad();
            }
        }
Exemple #3
0
        /// <summary>
        /// Also waits for dynamic contents to load (updater overlay to dissapear, pending ajax calls to finish) - due to some controls triggering overlay loader or ajax calls after being edited
        /// </summary>
        /// <param name="waitForItself"></param>
        /// <param name="waitForDynamicContentLoad"></param>
        public void Clear(bool waitForItself = true, bool waitForDynamicContentLoad = true) //param waitForItself must be default true because stale test needs to happen when it's used directly on control
        {
            if (waitForItself)
            {
                WaitForElementVisibleAndEnabled();
            }

            //			this.Element.Click();
            Element.Clear();

            if (waitForDynamicContentLoad)
            {
                ParentPage.WaitForDynamicContentToLoad();
            }
        }
Exemple #4
0
        /// <summary>
        /// Clicks and waits for the page to fully load: _title to change (if navigating to new page), updater overlay to dissapear, pending ajax calls to finish.
        /// VERY IMPORTANT: In case alerts appear use ClickAndTreatAlert() as it detects alerts
        /// </summary>
        /// <param name="waitForItself"></param>
        /// <param name="waitForPageToLoad"></param>
        /// <param name="alertResolveStatus">The way the popup/alert is treated. True = accept alert, False = cancel alert, DontResolve = leave alert</param>
        /// <param name="timeToWaitForAlert">Represents the time allocated for detecting the alert popup. Applies only to Accept and Dismiss alert resolve statuses. Value is in milliseconds</param>
        /// <param name="skipPageCreation"></param>
        /// <param name="waitForPageToLoadAfterAlert"></param>
        /// <returns></returns>
        public virtual object Click(bool waitForItself = true, bool waitForPageToLoad = true, AlertResolveType alertResolveStatus = AlertResolveType.TreatAfter, int timeToWaitForAlert = 500, bool skipPageCreation = false, bool waitForPageToLoadAfterAlert = true)
        {
            ParentPage.WaitForDynamicContentToLoad();

            var  result  = ClickNoWait(waitForItself, skipPageCreation);
            var  newPage = (result != null);
            bool pageAlert;

            if (newPage)
            {
                ((BasePage)result).WaitForAlert(timeToWaitForAlert);    //check for alert popups as default, but for treating them use ClickAndTreatAlert()
                _log.Info(String.Format("Click(): Page alert popup status = {0}.", ((BasePage)result).IsAlertPresent));
                pageAlert = ((BasePage)result).IsAlertPresent;
            }
            else
            {
                ParentPage.WaitForAlert(timeToWaitForAlert);
                _log.Info(String.Format("Click(): Page alert popup status = {0}", ParentPage.IsAlertPresent));
                pageAlert = ParentPage.IsAlertPresent;
            }

            if (pageAlert)
            {
                _log.Info(String.Format("Alert Message: {0}", ParentPage.Alert.Text));
                switch (alertResolveStatus)
                {
                case AlertResolveType.Accept:
                    if (newPage)
                    {
                        ((BasePage)result).AcceptAlert(waitForPageToLoadAfterAlert);
                    }
                    else
                    {
                        ParentPage.AcceptAlert(waitForPageToLoadAfterAlert);
                    }
                    break;

                case AlertResolveType.Dismiss:
                    if (newPage)
                    {
                        ((BasePage)result).DismissAlert(waitForPageToLoadAfterAlert);
                    }
                    else
                    {
                        ParentPage.DismissAlert(waitForPageToLoadAfterAlert);
                    }
                    break;

                case AlertResolveType.TreatAfter:
                    break;
                }
            }

            if (waitForPageToLoad && !pageAlert)
            {
                if (!newPage)
                {
                    ParentPage.WaitForDynamicContentToLoad();
                }
            }

            return(result);
        }