Example #1
0
        private List <WebElementInfo> FindElementInDescendants(CombinedWebElementInfo parent, string elementName)
        {
            var els           = new List <WebElementInfo>();
            var queue         = new Queue <CombinedWebElementInfo>();
            var childContexts = parent.GetChildContexts();

            foreach (var child in childContexts)
            {
                queue.Enqueue(child);
            }

            while (queue.Count > 0)
            {
                var currentContext = queue.Dequeue();
                var element        = currentContext.Elements.FirstOrDefault(e => e.Name == elementName);
                if (element != null)
                {
                    els.Add(element);
                }

                foreach (var child in currentContext.GetChildContexts())
                {
                    queue.Enqueue(child);
                }
            }

            return(els);
        }
Example #2
0
        private CombinedWebElementInfo FindContextInDescendants(CombinedWebElementInfo parent, string contextName)
        {
            var childContexts = parent.GetChildContexts();

            foreach (var child in childContexts)
            {
                if (child.Name == contextName)
                {
                    return(child);
                }
            }

            foreach (var child in childContexts)
            {
                var context = FindContextInDescendants(child, contextName);
                if (context != null)
                {
                    return(context);
                }
            }

            return(null);
        }