public static IEnumerable <IWebElement> Attempt(this IWebDriver driver, By by, Func <IWebDriver, IEnumerable <IWebElement> > condition, Func <IEnumerable <IWebElement>, IEnumerable <IWebElement> > actionBody, [CallerMemberName] string memberName = "", int?timeout = null, int retries = 0) { IEnumerable <IWebElement> elements = new List <IWebElement>(); try { elements = actionBody(ConditionWrapping.Condition(driver, condition, timeout)); } catch (Exception exception) when(exception is StaleElementReferenceException && retries < 1) { retries++; Attempt(driver, by, condition, actionBody, memberName, retries: retries); } catch (Exception exception) { ExceptionMessaging.ExceptionMessage(by, exception, memberName, timeout); Assert.Fail(); } return(elements); }
public static void AreRedirectsStopped(this IWebDriver driver, Func <IWebDriver, bool> condition, int?timeout = null) { try { ConditionWrapping.Condition(driver, condition); } catch (Exception e) { ExceptionMessaging.ExceptionMessage("redirects did not settle"); Assert.Fail(e.Message); } }