public static bool WaitUntilRested(this ISearchContext iSearchContext, Func <ISearchContext, bool> condition, int restTimeInSeconds, int maxWaitTimeInSeconds = GlobalConstants.MaxWaitTimeInSeconds) { if (restTimeInSeconds > maxWaitTimeInSeconds) { throw new ArgumentException("The restTimeInSeconds cannot be greater than the maxWaitTimeInSeconds"); } bool rested = false; var timeSpan = new Stopwatch(); timeSpan.Start(); while (timeSpan.Elapsed.Seconds <= 10 && rested == false) { if (iSearchContext.WaitUntil(ExpectedCondition.ElementRested(condition, restTimeInSeconds), maxWaitTimeInSeconds)) { rested = true; } } timeSpan.Stop(); return(rested); }