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);
     }
 }
Exemple #2
0
        public virtual IHtmlControl GetParentElement()
        {
            By          parentSelector = By.XPath("..");
            IWebElement parent         = Element.FindElement(parentSelector);

            return(HtmlControlFactory.GetHtmlElementInstance <HtmlControl>(parent, parentSelector));
        }
Exemple #3
0
        public IList <TElement> FindChildElements <TElement>(By selector) where TElement : class, IHtmlControl
        {
            IList <IWebElement> childElements = Element.FindElements(selector);

            return(childElements.Any() ? childElements.Select(x => HtmlControlFactory.GetHtmlElementInstance <TElement>(x, selector)).ToList() : new List <TElement>());
        }
Exemple #4
0
        public virtual TElement FindChildElement <TElement>(By selector) where TElement : class, IHtmlControl
        {
            IWebElement childElement = Element.FindElement(selector);

            return(HtmlControlFactory.GetHtmlElementInstance <TElement>(childElement, selector));
        }