Пример #1
0
        /// <summary>
        ///     Waits, until the <see cref="IWebElement" /> not exists.
        ///     <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 UntilElementNotExists([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 not exist.";

            return(wait.Until(WebDriverWaitConditions.ElementToNotExist(locator)));
        }