/// <summary> /// Waits for a <see cref="IWebElement"/> to not be visible in the page /// </summary> /// <param name="locators">The <see cref="By"/> locator of the <see cref="IWebElement"/></param> /// <param name="maxWaitTimeInSeconds">Maximum amount of seconds as <see cref="int"/> to wait for the <see cref="IWebElement"/> to become not visible</param> /// <returns><see langword="true"/> if the <see cref="IWebElement"/> is not visible; otherwise, <see langword="false"/></returns> public static bool WaitUntilNotVisible(this ISearchContext iSearchContext, List <By> locators, int maxWaitTimeInSeconds = GlobalConstants.MaxWaitTimeInSeconds) { var failedLocs = new List <By>(); foreach (var loc in locators) { if (iSearchContext.WaitUntil(ExpectedCondition.ElementNotVisible(loc), maxWaitTimeInSeconds)) { failedLocs.Add(loc); } } if (failedLocs.Count == 0) { return(true); } if (failedLocs.Count > 0 && maxWaitTimeInSeconds > 1) { return(iSearchContext.WaitUntilNotVisible(failedLocs, maxWaitTimeInSeconds / 2)); } if (failedLocs.Count > 0 && maxWaitTimeInSeconds <= 1) { return(false); } return(true); }
/// <summary> /// Waits for a <see cref="IWebElement"/> to not be visible in the page /// </summary> /// <param name="locator">The <see cref="By"/> locator of the <see cref="IWebElement"/></param> /// <param name="maxWaitTimeInSeconds">Maximum amount of seconds as <see cref="int"/> to wait for the <see cref="IWebElement"/> to become not visible</param> /// <returns><see langword="true"/> if the <see cref="IWebElement"/> is not visible; otherwise, <see langword="false"/></returns> public static bool WaitUntilNotVisible(this ISearchContext iSearchContext, By locator, int maxWaitTimeInSeconds = GlobalConstants.MaxWaitTimeInSeconds) { if (!iSearchContext.ElementExists(locator)) { Console.WriteLine("Element did not exist, element cannot be visable, by: {0}", locator); return(true); } return(iSearchContext.WaitUntil(ExpectedCondition.ElementNotVisible(locator), maxWaitTimeInSeconds)); }