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; }
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()); }
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; }
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); }
public static IEnumerable<DependencyObject> GetPopupsDescendantsBy(By searchStrategy) { var predicate = searchStrategy.Predicate; return GetPopupsDescendantsByPredicate(predicate, false); }
public static IEnumerable<DependencyObject> GetDescendantsBy(DependencyObject rootItem, By searchStrategy) { var predicate = searchStrategy.Predicate; return GetDescendantsByPredicate(rootItem, predicate, false); }