protected override string DoImpl() { var parentKey = this.ExecutedCommand.Parameters["ID"].ToString(); var searchValue = this.ExecutedCommand.Parameters["value"].ToString(); var searchStrategy = this.ExecutedCommand.Parameters["using"].ToString(); var parent = this.Automator.ElementsRegistry.GetRegisteredElement(parentKey); AutomationElement[] elements; if (searchStrategy.Equals("xpath")) { elements = ByXpath.FindAllByXPath(searchValue, parent.FlaUIElement); } else { var condition = ByHelper.GetStrategy(searchStrategy, searchValue); elements = parent.FlaUIElement.FindAllDescendants(condition); } var flaUiDriverElementList = elements .Select <AutomationElement, FlaUIDriverElement>((Func <AutomationElement, FlaUIDriverElement>)(x => new FlaUIDriverElement(x))) .ToList <FlaUIDriverElement>(); var registeredKeys = this.Automator.ElementsRegistry.RegisterElements(flaUiDriverElementList); var registeredObjects = registeredKeys.Select(e => new JsonElementContent(e)); return(this.JsonResponse(ResponseStatus.Success, registeredObjects)); }
protected override string DoImpl() { var parentKey = this.ExecutedCommand.Parameters["ID"].ToString(); var searchValue = this.ExecutedCommand.Parameters["value"].ToString(); var searchStrategy = this.ExecutedCommand.Parameters["using"].ToString(); var parent = this.Automator.ElementsRegistry.GetRegisteredElement(parentKey); AutomationElement element; if (searchStrategy.Equals("xpath")) { element = ByXpath.FindFirstByXPath(searchValue, parent.FlaUIElement); } else { var condition = ByHelper.GetStrategy(searchStrategy, searchValue); element = parent.FlaUIElement.FindFirstDescendant(condition); } if (element == null) { throw new AutomationException("Element cannot be found", ResponseStatus.NoSuchElement); } var registeredKey = this.Automator.ElementsRegistry.RegisterElement(new FlaUIDriverElement(element)); var registeredObject = new JsonElementContent(registeredKey); return(this.JsonResponse(ResponseStatus.Success, registeredObject)); }
protected override string DoImpl() { var searchValue = this.ExecutedCommand.Parameters["value"].ToString(); var searchStrategy = this.ExecutedCommand.Parameters["using"].ToString(); AutomationElement activeWindow = DriverManager.GetActiveWindow(); AutomationElement[] elements; if (searchStrategy.Equals("xpath")) { if (searchValue.StartsWith("#")) { searchValue = searchValue.TrimStart('#'); activeWindow = activeWindow.Automation.GetDesktop(); } elements = ByXpath.FindAllByXPath(searchValue, activeWindow); } else { var condition = ByHelper.GetStrategy(searchStrategy, searchValue); elements = activeWindow.FindAllDescendants(condition); } if (elements == null) { throw new AutomationException("Element cannot be found", ResponseStatus.NoSuchElement); } var flaUiDriverElementList = elements .Select <AutomationElement, FlaUIDriverElement>((Func <AutomationElement, FlaUIDriverElement>)(x => new FlaUIDriverElement(x))) .ToList <FlaUIDriverElement>(); var registeredKeys = this.Automator.ElementsRegistry.RegisterElements(flaUiDriverElementList); var registeredObjects = registeredKeys.Select(e => new JsonElementContent(e)); return(this.JsonResponse(ResponseStatus.Success, registeredObjects)); }
protected override string DoImpl() { var searchValue = this.ExecutedCommand.Parameters["value"].ToString(); var searchStrategy = this.ExecutedCommand.Parameters["using"].ToString(); AutomationElement activeWindow = DriverManager.GetActiveWindow(); AutomationElement element; if (searchStrategy.Equals("xpath")) { if (searchValue.StartsWith("#")) { searchValue = searchValue.TrimStart('#'); activeWindow = activeWindow.Automation.GetDesktop(); } element = ByXpath.FindFirstByXPath(searchValue, activeWindow); } else { var condition = ByHelper.GetStrategy(searchStrategy, searchValue); element = activeWindow.FindFirstDescendant(condition); } if (element == null) { throw new AutomationException("Element cannot be found", ResponseStatus.NoSuchElement); } var registeredKey = this.Automator.ElementsRegistry.RegisterElement(new FlaUIDriverElement(element)); var registeredObject = new JsonElementContent(registeredKey); return(this.JsonResponse(ResponseStatus.Success, registeredObject)); }