public TSelf WaitTill_ElementNotExists(By by, EnumSearchLocation location = EnumSearchLocation.IFrame, int timeoutInSeconds = 2, Action <IWebElement> callback = null) { if (location == EnumSearchLocation.MainWindow) { return(WaitTill_ElementNotExists_OnMain(by, timeoutInSeconds, callback)); } else { return(WaitTill_ElementNotExists_OnIFrame(by, timeoutInSeconds, callback)); } }
public TSelf Wait(int seconds, EnumSearchLocation location = EnumSearchLocation.IFrame) { if (location == EnumSearchLocation.MainWindow) { DriverHelpers.WaitForSometime(base.PrimaryDriver, seconds); } else { DriverHelpers.WaitForSometime(base.IFrameDriver, seconds); } return(this as TSelf); }
/// <summary> /// /// </summary> /// <param name="location"></param> /// <param name="by"></param> /// <param name="timeoutInSeconds"></param> /// <param name="textToCheck"></param> /// <param name="handlerMethod">Reference to the main class, element found, whether success or failed</param> /// <returns></returns> public TSelf WaitTill_TextToBePresentInElement(By by, string textToCheck, EnumSearchLocation location = EnumSearchLocation.IFrame, int timeoutInSeconds = 2, Action <TSelf, IWebElement, EnumElementCallStatus> handlerMethod = null) { var driver = base.PrimaryDriver; if (location == EnumSearchLocation.IFrame) { driver = base.IFrameDriver; } if (timeoutInSeconds <= 0) { #region when no timeout required IWebElement ele = driver.FindElement(by); if (ele == null) { if (handlerMethod == null) { throw new AurigoTestException(this, EnumExceptionType.ElementNotFound, by.ToString()); } else { handlerMethod(this as TSelf, ele, EnumElementCallStatus.ElementNotFound); } } else if (ele.Text == textToCheck) { if (handlerMethod != null) { handlerMethod(this as TSelf, ele, EnumElementCallStatus.Success); } } else { if (handlerMethod == null) { throw new AurigoTestException(this, EnumExceptionType.WaitOnElementNotMatched, "values not matching when waiting for TextToBePresentInElement"); } handlerMethod(this as TSelf, ele, EnumElementCallStatus.TimeOutError); } #endregion when no timeout required } else { #region when time is provided IWebElement ele = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutInSeconds)).Until(ExpectedConditions.ElementExists(by)); if (ele == null) { if (handlerMethod == null) { throw new AurigoTestException(this, EnumExceptionType.ElementNotFound, by.ToString()); } else { handlerMethod(this as TSelf, ele, EnumElementCallStatus.ElementNotFound); } } else { bool isPresent = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutInSeconds)).Until(ExpectedConditions.TextToBePresentInElement(ele, textToCheck)); if (isPresent) { handlerMethod(this as TSelf, ele, EnumElementCallStatus.Success); } else { if (handlerMethod == null) { throw new AurigoTestException(this, EnumExceptionType.WaitOnElementNotMatched, "values not matching when waiting for TextToBePresentInElement"); } else { handlerMethod(this as TSelf, ele, EnumElementCallStatus.TimeOutError); } } } #endregion when time is provided } return(this as TSelf); }