Exemple #1
0
        public TElement Find <TElement>(ISearchContext searchContext, By by) where TElement : class, IElement
        {
            var element = searchContext.FindElement(by.ToSeleniumBy());
            var result  = ResolveElement <TElement>(searchContext, element);

            return(result);
        }
Exemple #2
0
        public void WaitForDisplayed(IWebDriver driver, By by, TimeSpan timeout)
        {
            var wait = new WebDriverWait(driver, timeout)
            {
                PollingInterval = TimeSpan.FromSeconds(1.0)
            };

            wait.Until(x =>
            {
                var executor = (IJavaScriptExecutor)x;
                var element  = x.FindElement(by.ToSeleniumBy());

                return((bool)executor.ExecuteScript(
                           @"var rect = arguments[0].getBoundingClientRect();

                    return (
                        rect.top >= 0 &&
                        rect.left >= 0 &&
                        rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
                        rect.right <= (window.innerWidth || document.documentElement.clientWidth)
                    );", element));
            });
        }
Exemple #3
0
        public IEnumerable <TElement> FindAll <TElement>(ISearchContext searchContext, By by) where TElement : class, IElement
        {
            var elements = searchContext.FindElements(by.ToSeleniumBy());

            return(elements.Select(currentElement => ResolveElement <TElement>(searchContext, currentElement)));
        }