public static void WaitForLoadingOverlays(IWebDriver driver, int timeout = 200) { //TODO: Hack for network lag, must be removed. - <Pramod and 06/03/2017> ExplicitWait(); WebDriverHelpers.SetImplicitWait(TimeSpan.FromSeconds(0)); var wait = new WebDriverWait(driver, DefaultWait); wait.Until(ExpectedConditions.InvisibilityOfElementLocated(By.CssSelector(".loading-spinner"))); ExplicitWait(100); RecurseCount++; try { if (driver.FindElements(By.CssSelector(".loading-spinner")).Count(spnr => spnr.Displayed == true) > 1 && RecurseCount < timeout) { WaitForLoadingOverlays(driver); } } catch (Exception) { } RecurseCount = 0; WebDriverHelpers.SetImplicitWait(DefaultWait); WaitForAjaxLoad();//ToDo: remove - hack for net lag. }
/// <summary> /// Gets the count of the rows in the table. /// </summary> /// <param name="table">IWebElement table</param> /// <returns>Row count of the table.</returns> public static int Rowcount(this IWebElement table) { WebDriverHelpers.SetImplicitWait(TimeSpan.FromSeconds(3)); var y = table.FindElements(By.CssSelector("tbody>tr")).Count; //var x = table.FindElement(By.TagName("tbody")).FindElements(By.TagName("tr")).Count; WebDriverHelpers.SetImplicitWait(WaitHelpers.DefaultWait); return y; }
public static IWebElement WaitForElementExist(By locator) { WebDriverHelpers.SetImplicitWait(TimeSpan.Zero);//ToDo: remove once all elements use new func WebDriverWait waitExist = new WebDriverWait(WebDriverFactory.LastDriver, DefaultWait); waitExist.PollingInterval = TimeSpan.FromMilliseconds(500); waitExist.IgnoreExceptionTypes(typeof(NoSuchElementException)); waitExist.IgnoreExceptionTypes(typeof(StaleElementReferenceException)); IWebElement element = waitExist.Until <IWebElement>(ExpectedConditions.ElementExists(locator)); WebDriverHelpers.SetImplicitWait(DefaultWait);//ToDo: remove once all elements use new func return(element); }
public static void WaitForPresent(this IWebElement element, IWebDriver driver) //TODO: Could this be rolled into WaitForElementVisible? - MO { int timeoutCounter = 0; WebDriverHelpers.SetImplicitWait(TimeSpan.Zero); while (timeoutCounter < 100) { try { var x = element.Displayed; break; } catch (Exception) { ExplicitWait(100); timeoutCounter++; } } WebDriverHelpers.SetImplicitWait(DefaultWait); }