private static void Click(Func <IWebDriver, IWebElement> findFunction, BasicPageElement pageElement)
        {
            IWebElement   element = null;
            TimeSpan      timeout = new TimeSpan(0, 0, Settings.Default.TestTimeout);
            WebDriverWait wait    = new WebDriverWait(pageElement.WebDriver, timeout);

            if (pageElement.ParentPageObject.PageSettings.PageUsesJquery && !pageElement.ParentPageObject.PageSettings.HasEndlessJQueryAnimation)
            {
                string errorMessage = null;
                try
                {
                    Stopwatch stopwatch = Stopwatch.StartNew();
                    wait.Timeout = new TimeSpan(0, 0, 0, 0, Settings.Default.WatiForAnimationsToComplete);
                    wait.Until(driver => AllAnimationsFinished(driver, pageElement.ParentPageObject.PageSettings, out errorMessage));
                    TestLog.Add("Waited " + stopwatch.ElapsedMilliseconds + " milliseconds for all anmiations to complete.");
                }
                catch (WebDriverTimeoutException e)
                {
                    throw new TimeoutException(errorMessage + "  Waited " + Settings.Default.WatiForAnimationsToComplete + " milliseconds to complete animations. Inner-exception: ", e);
                }
            }

            try
            {
                wait.Timeout = timeout;
                element      = wait.Until(findFunction);
            }
            catch (WebDriverTimeoutException e)
            {
                string timeoutMessage = BuildTimeoutMessage(pageElement.By, Visibility.Hidden, e.Message, Settings.Default.TestTimeout, element);
                throw new TimeoutException(timeoutMessage, e);
            }

            element.Click();
        }
        /// <summary>
        /// Perfom a safe click on an element
        /// </summary>
        /// <param name="webDriver">the webdriver</param>
        /// <param name="pageElement">the webelement to click</param>
        public static void ClickElementWithoutScrolling(this IWebDriver webDriver, BasicPageElement pageElement)
        {
            Stopwatch startNew = Stopwatch.StartNew();

            Click(Find(pageElement.By, Visibility.Visible), pageElement);
            startNew.Stop();
            TestLog.Add("Waited " + startNew.ElapsedMilliseconds + " milliseconds to click element '" + pageElement.By + "'.");
        }
        /// <summary>
        /// Perfom a safe click on an element
        /// </summary>
        /// <param name="webDriver">the webdriver</param>
        /// <param name="pageElement">the webelement to click</param>
        public static void ClickElement(this IWebDriver webDriver, BasicPageElement pageElement)
        {
            Stopwatch startNew = Stopwatch.StartNew();

            Click(FindAndScrollToElement(pageElement.By, Visibility.Visible, pageElement.ParentPageObject.PageSettings), pageElement);
            startNew.Stop();
            TestLog.Add("Waited " + startNew.ElapsedMilliseconds + " milliseconds to scroll and click element '" + pageElement.By + "'.");
        }
		IFillable IFillBehaviourFactory.Create(FillBehaviour fillBehaviour, BasicPageElement pageElement)
		{
			switch (fillBehaviour)
			{
				case FillBehaviour.ClickFirstThenWaitForClear :
					return new FillBehaviourClickFirstThenWaitForClear(new FillbehaviourWaitForClearBeforeTyping(new DefaultFillBehaviour(pageElement), pageElement), pageElement);
				case FillBehaviour.WaitForClearBeforeTyping : 
					return new FillbehaviourWaitForClearBeforeTyping(new DefaultFillBehaviour(pageElement), pageElement);
				default: 
					return new DefaultFillBehaviour(pageElement);
			}
		}
		IClickable IClickBehaviourFactory.Create(ClickBehaviours clickBehaviour, BasicPageElement pageElement)
		{
			switch (clickBehaviour)
			{
				case ClickBehaviours.Default:
					return new DefaultClickBehaviour(pageElement);
				case ClickBehaviours.ClickWithoutScrolling:
					return new ClickElementWithoutScrollingBehaviour(pageElement);
				default:
					throw new Exception("Unknown clickBehaviour. RegTesting.Logic.ClickBehaviourFactory does not know the ClickBehaviour '" + clickBehaviour + "'.");
			}
		}
Example #6
0
        public static IFillable Create(FillBehaviour fillBehaviour, BasicPageElement pageElement)
        {
            switch (fillBehaviour)
            {
            case FillBehaviour.ClickFirstThenWaitForClear:
                return(new FillBehaviourClickFirstThenWaitForClear(new FillbehaviourWaitForClearBeforeTyping(new DefaultFillBehaviour(pageElement), pageElement), pageElement));

            case FillBehaviour.WaitForClearBeforeTyping:
                return(new FillbehaviourWaitForClearBeforeTyping(new DefaultFillBehaviour(pageElement), pageElement));

            default:
                return(new DefaultFillBehaviour(pageElement));
            }
        }
Example #7
0
        public static IClickable Create(ClickBehaviours clickBehaviour, BasicPageElement pageElement)
        {
            switch (clickBehaviour)
            {
            case ClickBehaviours.Default:
                return(new DefaultClickBehaviour(pageElement));

            case ClickBehaviours.ClickWithoutScrolling:
                return(new ClickElementWithoutScrollingBehaviour(pageElement));

            default:
                throw new Exception("Unknown clickBehaviour. RegTesting.Logic.ClickBehaviourFactory does not know the ClickBehaviour '" + clickBehaviour + "'.");
            }
        }
Example #8
0
        private static void Click(Func <IWebDriver, IWebElement> findFunction, BasicPageElement pageElement)
        {
            IWebElement   element = null;
            TimeSpan      timeout = new TimeSpan(0, 0, Settings.Default.TestTimeout);
            WebDriverWait wait    = new WebDriverWait(pageElement.WebDriver, timeout);

            try
            {
                element = wait.Until(findFunction);
            }
            catch (WebDriverTimeoutException e)
            {
                string timeoutMessage = BuildTimeoutMessage(pageElement.By, Visibility.Hidden, e.Message, Settings.Default.TestTimeout, element);
                throw new TimeoutException(timeoutMessage, e);
            }

            element.Click();
        }
		public FillBehaviourClickFirstThenWaitForClear(IFillable fillBehaviour, BasicPageElement pageElement)
		{
			_fillBehaviour = fillBehaviour;
			_pageElement = pageElement;
		}
		public FillbehaviourWaitForClearBeforeTyping(IFillable fillBehaviour, BasicPageElement pageElement)
		{
			_fillBehaviour = fillBehaviour;
			_pageElement = pageElement;
		}
		public DefaultSelectBehaviour(BasicPageElement pageElement)
		{
			_pageElement = pageElement;
		}
		public DefaultFillBehaviour(BasicPageElement pageElement)
		{
			_pageElement = pageElement;
		}
Example #13
0
 public void WaitFor(BasicPageElement element, Visibility visibility = Visibility.Visible)
 {
     _driver.WaitForElement(element.By, visibility);
 }
Example #14
0
 public void WaitForElementNotDisplayed(BasicPageElement element)
 {
     TestLog.Add("WaitForElementNotDisplayed: " + element.By);
     _driver.WaitForElement(element.By, Visibility.Hidden);
 }
Example #15
0
 /// <summary>
 /// Waits for an element to get visible.
 /// </summary>
 /// <param name="element">the element</param>
 /// <param name="timeout">A optional custom timeoutInSeconds (how long should we wait?)</param>
 public void WaitForElementDisplayed(BasicPageElement element, TimeSpan?timeout = null)
 {
     TestLog.Add("WaitForElementDisplayed: " + element.By);
     _driver.WaitForElement(element.By, timeout: timeout);
 }