Example #1
0
        /// <summary>
        /// Waits for element.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="waitCondition">The wait condition.</param>
        /// <param name="timeout">The timeout to wait before failing.</param>
        /// <returns><c>true</c> if the condition is met, <c>false</c> otherwise.</returns>
        public override bool WaitForElement(HtmlControl element, WaitConditions waitCondition, TimeSpan?timeout)
        {
            var milliseconds = (int)timeout.GetValueOrDefault(TimeSpan.FromSeconds(10)).TotalMilliseconds;

            switch (waitCondition)
            {
            case WaitConditions.Exists:
                return(element.WaitForControlExist(milliseconds));

            case WaitConditions.NotExists:
                return(element.WaitForControlNotExist(milliseconds));

            case WaitConditions.Enabled:
                return(element.WaitForControlCondition(e => e.Enabled, milliseconds));

            case WaitConditions.NotEnabled:
                return(element.WaitForControlCondition(e => !e.Enabled, milliseconds));

            case WaitConditions.NotMoving:
                element.WaitForControlExist(milliseconds);
                return(element.WaitForControlCondition(e => !this.Moving(e), milliseconds));
            }

            return(true);
        }