Exemplo n.º 1
0
 public static TElement TryWaitForElementToBeInDom <TElement>(this IWebDriver driver, By selector, IHtmlControl parent = null, int timeout = 45) where TElement : class, IHtmlControl
 {
     if (selector == null)
     {
         throw new Exception("'By' selector cannot be null.");
     }
     try
     {
         return(driver.WaitUntil(dr =>
         {
             try
             {
                 if (parent != null)
                 {
                     return parent.FindChildElement <TElement>(selector);
                 }
                 IWebElement element = driver.FindElement(selector);
                 return HtmlControlFactory.GetHtmlElementInstance <TElement>(element, selector);
             }
             catch (Exception)
             {
                 return null;
             }
         }, timeout));
     }
     catch (WebDriverTimeoutException)
     {
         return(null);
     }
 }