public static void WaitForAjaxSelectElementPopulated(this IWebDriver driver, By bySelectElement, double timeoutSeconds) { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutSeconds)); wait.Until(x => { try { SelectElement selectElement = new SelectElement(driver.AjaxFind(bySelectElement, timeoutSeconds)); return selectElement.Options.Any(); } catch (StaleElementReferenceException) { return false; } }); }
public static void WaitForAjaxSelectElementPopulatedWithElementText(this IWebDriver driver, By bySelectElement, string text, double timeoutSeconds) { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutSeconds)); wait.Until(x => { try { SelectElement selectElement = new SelectElement(driver.AjaxFind(bySelectElement, timeoutSeconds)); var element = selectElement.Options.Where(y => y.Text == text).FirstOrDefault(); return element!=null; } catch (StaleElementReferenceException) { return false; } }); }