public static void WaitForElementExists(this By by, IWebDriver driver, TimeSpan?timeout = null, bool suppressException = true) { var waitTimeout = timeout.IsNotNull() ? timeout.Value : AppConfig.ElementLoadWaitTime; try { var wait = new WebDriverWait(driver, waitTimeout); wait.IgnoreExceptionTypes(typeof(NoSuchElementException)); wait.Until(d => by.Exists(d)); } catch (WebDriverTimeoutException ex) { Console.WriteLine("Element Timeout Exception. " + ex.Message); if (!suppressException) { throw; } } catch (Exception ex) { Console.WriteLine("Exception thrown. Please see Exception details " + ex.Message); if (!suppressException) { throw; } } }
public static void ActionClick(this By selector) { selector.WaitForElementToBeClickable(); if (!selector.Exists()) { return; } Browser.WebDriver.FindElement(selector).Click(); }
public static void ClearField(this By selector) { selector.WaitForElement(); if (!selector.Exists()) { return; } Browser.WebDriver.FindElement(selector).Clear(); }
public static void ActionSendKeys(this By selector, string text) { selector.WaitForElement(); if (!selector.Exists() || string.IsNullOrEmpty(text)) { return; } selector.ClearField(); Browser.WebDriver.FindElement(selector).SendKeys(text); }