Ejemplo n.º 1
0
        private IEnumerable<string> FindElementsBy(DependencyObject relativeElement, By searchStrategy)
        {
            var foundIds = new List<string>();
            var descendant = Finder.GetDescendantsBy(relativeElement, searchStrategy);
            if (relativeElement == this.Automator.VisualRoot)
            {
                descendant = descendant.Concat(Finder.GetPopupsDescendantsBy(searchStrategy));
            }

            foundIds.AddRange(
                descendant.Select(element => this.Automator.WebElements.RegisterElement((FrameworkElement)element)));
            return foundIds;
        }
Ejemplo n.º 2
0
        public override string DoImpl()
        {
            var searchValue = this.Parameters["value"].ToString();
            var searchPolicy = this.Parameters["using"].ToString();

            DependencyObject relativeElement = this.ElementId == null
                                                   ? this.Automator.VisualRoot
                                                   : this.Automator.WebElements.GetRegisteredElement(this.ElementId);

            var result = new List<JsonWebElementContent>();
            var searchStrategy = new By(searchPolicy, searchValue);
            var foundObjectsIdList = this.FindElementsBy(relativeElement, searchStrategy);
            result.AddRange(foundObjectsIdList.Select(foundObjectId => new JsonWebElementContent(foundObjectId)));

            return this.JsonResponse(ResponseStatus.Success, result.ToArray());
        }
Ejemplo n.º 3
0
        private string FindElementBy(DependencyObject relativeElement, By searchStrategy)
        {
            string foundId = null;
            var descendant = Finder.GetDescendantsBy(relativeElement, searchStrategy);
            if (relativeElement == this.Automator.VisualRoot)
            {
                descendant = descendant.Concat(Finder.GetPopupsDescendantsBy(searchStrategy));
            }

            var element = (FrameworkElement)descendant.FirstOrDefault();
            if (element != null)
            {
                foundId = this.Automator.WebElements.RegisterElement(element);
            }

            return foundId;
        }
Ejemplo n.º 4
0
        public override string DoImpl()
        {
            var searchValue = this.Parameters["value"].ToString();
            var searchPolicy = this.Parameters["using"].ToString();

            DependencyObject relativeElement = this.ElementId == null
                                                   ? this.Automator.VisualRoot
                                                   : this.Automator.WebElements.GetRegisteredElement(this.ElementId);

            var searchStrategy = new By(searchPolicy, searchValue);
            var webObjectId = this.FindElementBy(relativeElement, searchStrategy);

            if (webObjectId == null)
            {
                throw new AutomationException("Element cannot be found", ResponseStatus.NoSuchElement);
            }

            var webElement = new JsonWebElementContent(webObjectId);
            return this.JsonResponse(ResponseStatus.Success, webElement);
        }
Ejemplo n.º 5
0
        public static IEnumerable<DependencyObject> GetPopupsDescendantsBy(By searchStrategy)
        {
            var predicate = searchStrategy.Predicate;

            return GetPopupsDescendantsByPredicate(predicate, false);
        }
Ejemplo n.º 6
0
        public static IEnumerable<DependencyObject> GetDescendantsBy(DependencyObject rootItem, By searchStrategy)
        {
            var predicate = searchStrategy.Predicate;

            return GetDescendantsByPredicate(rootItem, predicate, false);
        }