Пример #1
0
        /// <summary>
        ///     Waits, until the <see cref="IWebElement" /> has become Enabled.
        ///     <para>
        ///         Exceptions ignored until timeout: <see cref="NoSuchElementException" />,
        ///         <see cref="StaleElementReferenceException" />
        ///     </para>
        /// </summary>
        /// <param name="wait">The <see cref="WebDriverWait" /> instance, that is used to command the browser for wait.</param>
        /// <param name="locator">
        ///     <inheritdoc cref="ISearchContext.FindElement(By)" />
        /// </param>
        /// <exception cref="WebDriverTimeoutException"></exception>
        /// <exception cref="NoSuchElementException"></exception>
        /// <exception cref="StaleElementReferenceException"></exception>
        public static bool UntilElementIsEnabled([NotNull] this WebDriverWait wait, [NotNull] By locator)
        {
            if (wait == null)
            {
                throw new ArgumentNullException(nameof(wait));
            }
            if (locator == null)
            {
                throw new ArgumentNullException(nameof(locator));
            }

            wait.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(StaleElementReferenceException));
            wait.Message += " Waited for " +
                            $"({locator} in the Document) element " +
                            "to become Enabled.";

            return(wait.Until(WebDriverWaitConditions.ElementToBecomeEnabled(locator)));
        }
Пример #2
0
        /// <summary>
        ///     Waits, until the <see cref="IWebElement" /> has become Enabled.
        ///     <para>Exceptions ignored until timeout: <see cref="StaleElementReferenceException" /></para>
        /// </summary>
        /// <param name="wait">The <see cref="WebDriverWait" /> instance, that is used to command the browser for wait.</param>
        /// <param name="element">The HTMLElement, that is represented by an <see cref="IWebElement" /> instance.</param>
        /// <exception cref="WebDriverTimeoutException"></exception>
        /// <exception cref="StaleElementReferenceException"></exception>
        public static bool UntilElementIsEnabled([NotNull] this WebDriverWait wait, [NotNull] IWebElement element)
        {
            if (wait == null)
            {
                throw new ArgumentNullException(nameof(wait));
            }
            if (element == null)
            {
                throw new ArgumentNullException(nameof(element));
            }

            wait.IgnoreExceptionTypes(typeof(StaleElementReferenceException));
            wait.Message += " Waited for " +
                            $"({element}) element " +
                            "to become Enabled.";

            return(wait.Until(WebDriverWaitConditions.ElementToBecomeEnabled(element)));
        }