/// <summary> /// Waits, until the <see cref="IWebElement" />'s given property has met the given condition. /// <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="condition"> /// The <see cref="Func{T,TResult}" />, that defines the condition until the browser must /// wait. /// </param> /// <param name="propertyName">The property's name of the <see cref="IWebElement" />.</param> /// <param name="searchContext">The <see cref="ISearchContext" /> within we search for the element.</param> /// <param name="locator"> /// <inheritdoc cref="ISearchContext.FindElement(By)" /> /// </param> /// <exception cref="WebDriverTimeoutException"></exception> /// <exception cref="NoSuchElementException"></exception> /// <exception cref="StaleElementReferenceException"></exception> public static TResult UntilElementProperty <TResult>([NotNull] this WebDriverWait wait, [NotNull] ISearchContext searchContext, [NotNull] By locator, [NotNull] string propertyName, [NotNull] Func <object, TResult> condition) { if (wait == null) { throw new ArgumentNullException(nameof(wait)); } if (searchContext == null) { throw new ArgumentNullException(nameof(searchContext)); } if (locator == null) { throw new ArgumentNullException(nameof(locator)); } if (propertyName == null) { throw new ArgumentNullException(nameof(propertyName)); } if (condition == null) { throw new ArgumentNullException(nameof(condition)); } wait.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(StaleElementReferenceException)); wait.Message += " Waited for " + $"element's ({propertyName}) property " + "to meet the given condition."; return(wait.Until(WebDriverWaitConditions.ElementProperty(searchContext, locator, propertyName, condition))); }
/// <summary> /// Waits, until the <see cref="IWebElement" />'s given property has met the given condition. /// <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="condition">The <see cref="Func{T,TResult}" />, that defines the condition until the browser must wait.</param> /// <param name="propertyName">The property's name of the <see cref="IWebElement" />.</param> /// <param name="element">The HTMLElement, that is represented by an <see cref="IWebElement" /> instance.</param> /// <exception cref="WebDriverTimeoutException"></exception> /// <exception cref="WebDriverException"></exception> /// <exception cref="StaleElementReferenceException"></exception> public static TResult UntilElementProperty <TResult>([NotNull] this WebDriverWait wait, [NotNull] IWebElement element, [NotNull] string propertyName, [NotNull] Func <object, TResult> condition) { if (wait == null) { throw new ArgumentNullException(nameof(wait)); } if (element == null) { throw new ArgumentNullException(nameof(element)); } if (propertyName == null) { throw new ArgumentNullException(nameof(propertyName)); } if (condition == null) { throw new ArgumentNullException(nameof(condition)); } wait.IgnoreExceptionTypes(typeof(StaleElementReferenceException)); wait.Message += " Waited for " + $"({element}) element's ({propertyName}) property " + "to meet the given condition."; return(wait.Until(WebDriverWaitConditions.ElementProperty(element, propertyName, condition))); }
/// <summary> /// Waits, until the <see cref="IWebElement" />'s given style property has met the given condition. /// <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="condition"> /// The <see cref="Func{T,TResult}" />, that defines the condition until the browser must /// wait. /// </param> /// <param name="stylePropertyName">The style property's name of the <see cref="IWebElement" />.</param> /// <param name="locator"> /// <inheritdoc cref="ISearchContext.FindElement(By)" /> /// </param> /// <exception cref="WebDriverTimeoutException"></exception> /// <exception cref="NoSuchElementException"></exception> /// <exception cref="StaleElementReferenceException"></exception> public static TResult UntilElementStyleProperty <TResult>([NotNull] this WebDriverWait wait, [NotNull] By locator, [NotNull] string stylePropertyName, [NotNull] Func <string, TResult> condition) { if (wait == null) { throw new ArgumentNullException(nameof(wait)); } if (locator == null) { throw new ArgumentNullException(nameof(locator)); } if (stylePropertyName == null) { throw new ArgumentNullException(nameof(stylePropertyName)); } if (condition == null) { throw new ArgumentNullException(nameof(condition)); } wait.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(StaleElementReferenceException)); wait.Message += " Waited for " + $"({locator} in the Document) element's ({stylePropertyName}) style property " + "to meet the given condition."; return(wait.Until(WebDriverWaitConditions.ElementStyleProperty(locator, stylePropertyName, condition))); }
/// <summary> /// Waits, until the Document.readyState is equals with the expected value. /// </summary> /// <param name="expectedDocumentReadyState">The Document.readyState property describes the loading state of the document.</param> /// <param name="wait">The <see cref="WebDriverWait" /> instance, that is used to command the browser for wait.</param> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="WebDriverTimeoutException"></exception> /// <exception cref="WebDriverException"></exception> public static bool UntilDocumentReadyState( [NotNull] this WebDriverWait wait, DocumentReadyState expectedDocumentReadyState) { if (wait == null) { throw new ArgumentNullException(nameof(wait)); } wait.Message += " Waited for " + $"({expectedDocumentReadyState.ToString().ToLower()}) document readyState " + $"to be ({expectedDocumentReadyState})"; return(wait.Until(WebDriverWaitConditions.DocumentReadyStateToBe(expectedDocumentReadyState))); }
/// <summary> /// Waits, until the <see cref="IWebElement" /> has become not Selected. /// <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 UntilElementIsNotSelected([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 not Selected."; return(wait.Until(WebDriverWaitConditions.ElementToBecomeNotSelected(element))); }
/// <summary> /// Waits, until the browser's loaded Url should meet the given condition. /// </summary> /// <param name="wait">The <see cref="WebDriverWait" /> instance, that is used to command the browser for wait.</param> /// <param name="condition">The <see cref="Func{T,TResult}" />, that defines the condition until the browser must wait.</param> /// <exception cref="WebDriverTimeoutException"></exception> public static TResult UntilUrl <TResult>( [NotNull] this WebDriverWait wait, [NotNull] Func <Uri, TResult> condition) { if (wait == null) { throw new ArgumentNullException(nameof(wait)); } if (condition == null) { throw new ArgumentNullException(nameof(condition)); } wait.Message += " Waited for " + "loaded url " + "to meet the given condition."; return(wait.Until(WebDriverWaitConditions.Url(condition))); }
/// <summary> /// Waits, until the browser's loaded Url should to be the given value. /// </summary> /// <param name="wait">The <see cref="WebDriverWait" /> instance, that is used to command the browser for wait.</param> /// <param name="url">The URL the browser is currently displaying.</param> /// <exception cref="WebDriverTimeoutException"></exception> public static bool UntilUrlToBe( [NotNull] this WebDriverWait wait, [NotNull] string url) { if (wait == null) { throw new ArgumentNullException(nameof(wait)); } if (url == null) { throw new ArgumentNullException(nameof(url)); } wait.Message += " Waited for " + "loaded url " + $"to be ({url})"; return(wait.Until(WebDriverWaitConditions.UrlToBe(url))); }
/// <summary> /// Waits, until the browser's loaded Url should not match the regular expression. /// </summary> /// <param name="wait">The <see cref="WebDriverWait" /> instance, that is used to command the browser for wait.</param> /// <param name="regexPattern">The regular expression pattern.</param> /// <exception cref="WebDriverTimeoutException"></exception> /// <exception cref="ArgumentException"></exception> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="RegexMatchTimeoutException"></exception> public static bool UntilUrlNotMatches( [NotNull] this WebDriverWait wait, [NotNull] string regexPattern) { if (wait == null) { throw new ArgumentNullException(nameof(wait)); } if (regexPattern == null) { throw new ArgumentNullException(nameof(regexPattern)); } wait.Message += " Waited for " + "loaded url " + $"to not match with the regular expression ({regexPattern})."; return(wait.Until(WebDriverWaitConditions.UrlNotMatches(regexPattern))); }
/// <summary> /// Waits, until the browser's loaded Url should not contain the given value. /// </summary> /// <param name="wait">The <see cref="WebDriverWait" /> instance, that is used to command the browser for wait.</param> /// <param name="urlPart">The URL part the browser is currently displaying.</param> /// <exception cref="WebDriverTimeoutException"></exception> public static bool UntilUrlNotContains( [NotNull] this WebDriverWait wait, [NotNull] string urlPart) { if (wait == null) { throw new ArgumentNullException(nameof(wait)); } if (urlPart == null) { throw new ArgumentNullException(nameof(urlPart)); } wait.Message += " Waited for " + "loaded url " + $"not to contain ({urlPart})"; return(wait.Until(WebDriverWaitConditions.UrlNotToContain(urlPart))); }
/// <summary> /// Waits, until the browser's loaded Url should not contain the given value. /// </summary> /// <param name="wait">The <see cref="WebDriverWait" /> instance, that is used to command the browser for wait.</param> /// <param name="uriPartial"> /// <inheritdoc cref="Uri.GetLeftPart(UriPartial)" /> /// </param> /// <param name="condition">The <see cref="Func{T,TResult}" />, that defines the condition until the browser must wait.</param> /// <exception cref="WebDriverTimeoutException"></exception> public static TResult UntilUrlLeftPart <TResult>( [NotNull] this WebDriverWait wait, UriPartial uriPartial, [NotNull] Func <string, TResult> condition) { if (wait == null) { throw new ArgumentNullException(nameof(wait)); } if (condition == null) { throw new ArgumentNullException(nameof(condition)); } wait.Message += " Waited for " + "loaded url's left part " + "to meet the given condition."; return(wait.Until(WebDriverWaitConditions.UrlLeftPart(uriPartial, condition))); }