Пример #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;
        }
Пример #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());
        }
Пример #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;
        }
Пример #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);
        }
Пример #5
0
        public static IEnumerable<DependencyObject> GetPopupsDescendantsBy(By searchStrategy)
        {
            var predicate = searchStrategy.Predicate;

            return GetPopupsDescendantsByPredicate(predicate, false);
        }
Пример #6
0
        public static IEnumerable<DependencyObject> GetDescendantsBy(DependencyObject rootItem, By searchStrategy)
        {
            var predicate = searchStrategy.Predicate;

            return GetDescendantsByPredicate(rootItem, predicate, false);
        }