/// <summary>
        /// Executes this instance action.
        /// </summary>
        /// <param name="actionContext">The action context.</param>
        /// <returns>The result of the action.</returns>
        protected override ActionResult Execute(WaitForListItemsContext actionContext)
        {
            // Get the element
            var propertyName = actionContext.PropertyName;
            var element      = this.GetProperty(propertyName);

            // Make sure the element is a list
            if (!element.IsList)
            {
                var exception =
                    new ElementExecuteException(
                        "Property '{0}' is not a list and cannot be used in this wait.",
                        propertyName);

                return(ActionResult.Failure(exception));
            }

            // Setup timeout items
            var timeout      = actionContext.Timeout.GetValueOrDefault(DefaultTimeout);
            var waitInterval = TimeSpan.FromMilliseconds(200);
            var waiter       = new Waiter(timeout, waitInterval);

            try
            {
                waiter.WaitFor(() => this.CheckForPage(element));

                return(ActionResult.Successful());
            }
            catch (TimeoutException)
            {
                var exception = new ElementExecuteException("List '{0}' did not contain elements after {1}", propertyName, timeout);
                return(ActionResult.Failure(exception));
            }
        }
        /// <summary>
        /// Executes this instance action.
        /// </summary>
        /// <param name="actionContext">The action context.</param>
        /// <returns>The result of the action.</returns>
        protected override ActionResult Execute(WaitForListItemsContext actionContext)
        {
            // Get the element
            var propertyName = actionContext.PropertyName;
            var element      = this.ElementLocator.GetProperty(propertyName);

            // Make sure the element is a list
            if (!element.IsList)
            {
                var exception =
                    new ElementExecuteException(
                        "Property '{0}' is not a list and cannot be used in this wait.",
                        propertyName);

                return(ActionResult.Failure(exception));
            }

            // Setup timeout items
            var timeout = actionContext.Timeout.GetValueOrDefault(TimeSpan.FromSeconds(20));
            var cancellationTokenSource = new CancellationTokenSource();

            cancellationTokenSource.CancelAfter(timeout);
            var token = cancellationTokenSource.Token;

            try
            {
                var task = Task.Run(() => this.CheckForPage(element, token), token);
                task.Wait(token);

                return(ActionResult.Successful());
            }
            catch (OperationCanceledException)
            {
                var exception = new PageNavigationException("List '{0}' did not contain elements after {1}", propertyName, timeout);
                return(ActionResult.Failure(exception));
            }
        }