public IEnumerable <WiniumElement> IterFind(TreeScope scope, Predicate <WiniumElement> predicate)
        {
            if (scope != TreeScope.Descendants && scope != TreeScope.Children)
            {
                throw new ArgumentException("scope should be one of TreeScope.Descendants or TreeScope.Children");
            }

            var walker = new TreeWalker(Condition.TrueCondition);

            var elementNode = walker.GetFirstChild(this.AutomationElement);

            while (elementNode != null)
            {
                var winiumElement = new WiniumElement(elementNode);

                if (predicate == null || predicate(winiumElement))
                {
                    yield return(winiumElement);
                }

                if (scope == TreeScope.Descendants)
                {
                    foreach (var descendant in winiumElement.IterFind(scope, predicate))
                    {
                        yield return(descendant);
                    }
                }

                elementNode = walker.GetNextSibling(elementNode);
            }
        }
        public string FindElement(WiniumElement root, By strategy)
        {
            var element = root.IterFind(TreeScope.Descendants, strategy.Predicate).FirstOrDefault();

            if (element == null)
            {
                throw new AutomationException("Element could not be found.", ResponseStatus.NoSuchElement);
            }

            return this.RegisterElement(element);
        }
Esempio n. 3
0
        public string FindElement(WiniumElement root, By strategy)
        {
            var element = root.IterFind(TreeScope.Descendants, strategy.Predicate).FirstOrDefault();

            if (element == null)
            {
                throw new AutomationException("Element could not be found.", ResponseStatus.NoSuchElement);
            }

            return(this.RegisterElement(element));
        }
Esempio n. 4
0
        public string RegisterElement(WiniumElement element)
        {
            Interlocked.Increment(ref safeInstanceCount);

            var registeredKey = string.Format(CultureInfo.InvariantCulture,
                                              "{0}-{1}",
                                              element.GetHashCode(),
                                              safeInstanceCount.ToString(string.Empty, CultureInfo.InvariantCulture));

            this.registeredElements.Add(registeredKey, element);

            return(registeredKey);
        }
        public string RegisterElement(WiniumElement element)
        {
            Interlocked.Increment(ref safeInstanceCount);

            var registeredKey = string.Format(CultureInfo.InvariantCulture,
                "{0}-{1}", 
                element.GetHashCode(), 
                safeInstanceCount.ToString(string.Empty, CultureInfo.InvariantCulture));
            this.registeredElements.Add(registeredKey, element);

            return registeredKey;
        }
        public List<string> FindElements(WiniumElement root, By strategy)
        {
            var elements = root.IterFind(TreeScope.Descendants, strategy.Predicate);

            return elements.Select(this.RegisterElement).ToList();
        }
        public IEnumerable<WiniumElement> IterFind(TreeScope scope, Predicate<WiniumElement> predicate)
        {
            if (scope != TreeScope.Descendants && scope != TreeScope.Children)
            {
                throw new ArgumentException("scope should be one of TreeScope.Descendants or TreeScope.Children");
            }

            var walker = new TreeWalker(Condition.TrueCondition);

            var elementNode = walker.GetFirstChild(this.AutomationElement);

            while (elementNode != null)
            {
                var winiumElement = new WiniumElement(elementNode);

                if (predicate == null || predicate(winiumElement))
                {
                    yield return winiumElement;
                }

                if (scope == TreeScope.Descendants)
                {
                    foreach (var descendant in winiumElement.IterFind(scope, predicate))
                    {
                        yield return descendant;
                    }
                }

                elementNode = walker.GetNextSibling(elementNode);
            }
        }
Esempio n. 8
0
        public List <string> FindElements(WiniumElement root, By strategy)
        {
            var elements = root.IterFind(TreeScope.Descendants, strategy.Predicate);

            return(elements.Select(this.RegisterElement).ToList());
        }