Example #1
0
        /// <summary>
        ///     Finds the element.
        ///     Will poll the interface on a regular basis until the element is present.
        ///     If element not present after polling then perform error handling and try load element again.
        /// </summary>
        /// <returns>
        ///     <see cref="IWebElement" /> instance.
        /// </returns>
        public override IWebElement FindElement()
        {
            var loadingElement = new SlowLoadingElement(clock, TimeoutInSeconds, SleepInterval, base.FindElement, IsElementUsable);

            try
            {
                return(loadingElement.Load().Element);
            }
            catch (Exception exception)
            {
                if (exception is WebDriverException || exception is RuntimeBinderException)
                {
                    var reloadElement = false;
                    var lastException = exception;
                    if (!ErrorHandlingEnabled)
                    {
                        throw lastException;
                    }
                    foreach (var errorHandler in UIErrorHandlersContainer.ErrorHandlers)
                    {
                        if (errorHandler.ErrorExists)
                        {
                            reloadElement = true;
                        }
                        errorHandler.HandleError();
                    }
                    if (reloadElement)
                    {
                        return(loadingElement.Load().Element);
                    }
                    throw lastException;
                }
                throw;
            }
        }
        public override IWebElement FindElement()
        {
            SlowLoadingElement loadingElement = new SlowLoadingElement(clock, timeOutInSeconds, SleepInterval, base.FindElement, this.IsElementUsable);

            try
            {
                return(loadingElement.Load().Element);
            }
            catch (NoSuchElementException e)
            {
                throw new NoSuchElementException(
                          string.Format("Timed out after {0} seconds. {1}", timeOutInSeconds, e.Message),
                          e.InnerException);
            }
        }