protected override string DoImpl() { var chars = this.ExecutedCommand.Parameters["value"].Select(x => Convert.ToChar(x.ToString())); DriverManager.GetActiveWindow().SetForeground(); this.Automator.FlaNiumKeyboard.SendKeys(chars.ToArray()); return(this.JsonResponse()); }
protected override string DoImpl() { var activeWindow = DriverManager.GetActiveWindow(); var itemRegisteredKey = this.Automator.ElementsRegistry.RegisterElement(new FlaUIDriverElement(activeWindow)); var registeredObject = new JsonElementContent(itemRegisteredKey); return(this.JsonResponse(ResponseStatus.Success, registeredObject)); }
protected override string DoImpl() { AutomationElement uiItem = DriverManager.GetActiveWindow().Automation.FocusedElement(); if (uiItem == null) { throw new AutomationException("Active cannot be found ", ResponseStatus.NoSuchElement); } var registeredKey = this.Automator.ElementsRegistry.RegisterElement(new FlaUIDriverElement(uiItem)); var registeredObject = new JsonElementContent(registeredKey); return(this.JsonResponse(ResponseStatus.Success, registeredObject)); }
protected override string DoImpl() { string title = this.ExecutedCommand.Parameters["name"].ToString(); try { DriverManager.SwitchWindow(title); return(this.JsonResponse(ResponseStatus.Success, (object)DriverManager.GetActiveWindow().Title)); } catch (NullReferenceException ex) { return(this.JsonResponse(ResponseStatus.NoSuchWindow, (object)ex)); } catch (AccessViolationException ex) { return(this.JsonResponse(ResponseStatus.ElementIsNotSelectable, (object)ex)); } }
protected override string DoImpl() { var haveElement = this.ExecutedCommand.Parameters.ContainsKey("element"); var haveOffset = this.ExecutedCommand.Parameters.ContainsKey("xoffset") && this.ExecutedCommand.Parameters.ContainsKey("yoffset"); if (!(haveElement || haveOffset)) { // TODO: in the future '400 : invalid argument' will be used return(this.JsonResponse(ResponseStatus.UnknownError, "WRONG PARAMETERS")); } var resultPoint = Mouse.Position; if (haveElement) { var registeredKey = this.ExecutedCommand.Parameters["element"].ToString(); FlaUIDriverElement element = this.Automator.ElementsRegistry.GetRegisteredElementOrNull(registeredKey); if (element != null) { var rect = element.Properties.BoundingRectangle; resultPoint.X = rect.Left; resultPoint.Y = rect.Top; if (!haveOffset) { resultPoint.X += rect.Width / 2; resultPoint.Y += rect.Height / 2; } } } if (haveOffset) { resultPoint.X += Convert.ToInt32(this.ExecutedCommand.Parameters["xoffset"]); resultPoint.Y += Convert.ToInt32(this.ExecutedCommand.Parameters["yoffset"]); } DriverManager.GetActiveWindow(); Mouse.MoveTo(resultPoint.X, resultPoint.Y); return(this.JsonResponse()); }
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 buttonId = Convert.ToInt32(this.ExecutedCommand.Parameters["button"]); DriverManager.GetActiveWindow().SetForeground(); switch ((MouseButton)buttonId) { case MouseButton.Left: Mouse.LeftClick(); break; case MouseButton.Right: Mouse.RightClick(); break; default: return(this.JsonResponse(ResponseStatus.UnknownCommand, "Mouse button behavior is not implemented")); } return(this.JsonResponse()); }
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)); }
protected override string DoImpl() { DriverManager.GetActiveWindow().Patterns.Window.Pattern.SetWindowVisualState(WindowVisualState.Maximized); return(this.JsonResponse()); }