public override void Execute(ActivityContext context) { var query = ElementQuery.Get(this.Element); if (query == null) { throw new Exception("Input 'Element' is required."); } var elements = WinContext.Shared.GetElementsFromQuery(query); if (elements.Count() == 0) { throw new Exception("Element not found."); } if (elements.Count() > 1) { throw new Exception("Too many elements found."); } var text = context.Get(this.Text); var e = elements.First() as WinElement; e.Focus(); SendKeys.SendWait(text); }
public override void Execute(ActivityContext context) { var query = ElementQuery.Get(this.Element); var elements = WinContext.Shared.GetElementsFromQuery(query); if (elements.Count() == 0) { throw new Exception("Element not found."); } if (elements.Count() > 1) { throw new Exception("Too many elements found."); } var e = elements.First() as WinElement; var name = context.Get(this.PropertyName); if (e.GetType().GetProperty(name, BindingFlags.Public | BindingFlags.Instance) is PropertyInfo pi) { context.Set(this.PropertyValue, pi.GetValue(e)?.ToString() ?? string.Empty); } else { throw new Exception(string.Format("Element property '{0}' not found.", name)); } }
public override void Execute(ActivityContext context) { var query = ElementQuery.Get(this.Element); if (query == null) { return; } var elements = WinContext.Shared.GetElementsFromQuery(query); if (elements.Count() == 0) { throw new Exception("Element not found."); } if (elements.Count() > 1) { throw new Exception("Too many elements found."); } using (var input = new InputDriver()) { var e = elements.First() as WinElement; e.Focus(); e.Click(); } }
public async Task HasNoItemsExpanderVisibility_SetOnTreeView_ChangesVisibiliyOnExpanders(Visibility visibility) { await using var recorder = new TestRecorder(App); var treeView = await LoadXaml <TreeView>($@" <TreeView materialDesign:TreeViewAssist.HasNoItemsExpanderVisibility=""{visibility}""> <TreeViewItem Header=""NoChild"" /> <TreeViewItem Header=""HasChild""> <TreeViewItem Header=""Child"" /> </TreeViewItem> </TreeView>"); var expander = await GetExpanderForHeader("NoChild"); Assert.Equal(visibility, await expander.GetVisibility()); expander = await GetExpanderForHeader("HasChild"); Assert.Equal(Visibility.Visible, await expander.GetVisibility()); recorder.Success(); async Task <IVisualElement <ToggleButton> > GetExpanderForHeader(string header) { var item = await treeView !.GetElement(ElementQuery.PropertyExpression <TreeViewItem>(x => x.Header, header)); return(await item.GetElement <ToggleButton>()); } }
public async Task OnEditableComboBox_WithDefaultContextMenu_ShowsCutCopyPaste() { await using var recorder = new TestRecorder(App); var comboBox = await LoadXaml <ComboBox>(@" <ComboBox IsEditable=""True"" Width=""200"" Style=""{StaticResource MaterialDesignComboBox}""> <ComboBoxItem Content=""Select1"" /> <ComboBoxItem>Select2</ComboBoxItem> <ComboBoxItem>Select3</ComboBoxItem> <ComboBoxItem>Select4</ComboBoxItem> <ComboBoxItem>Select5</ComboBoxItem> </ComboBox>"); await comboBox.RightClick(); IVisualElement <ContextMenu>?contextMenu = await comboBox.GetContextMenu(); Assert.True(contextMenu is not null, "No context menu set on the ComboBox"); await AssertMenu("Cut"); await AssertMenu("Copy"); await AssertMenu("Paste"); recorder.Success(); async Task AssertMenu(string menuHeader) { var menuItem = await contextMenu !.GetElement(ElementQuery.PropertyExpression <MenuItem>(x => x.Header, menuHeader)); Assert.True(menuItem is not null, $"{menuHeader} menu item not found"); } }
public async static Task <Tuple <IList <JointValues>, int> > QueryJointValuesByPrefix( [InputPin(PropertyMode = PropertyMode.Default)] string folderPath = "", [InputPin(PropertyMode = PropertyMode.Default)] string prefix = "", [InputPin(PropertyMode = PropertyMode.Default)] bool recursive = true, CancellationToken cancel = default(CancellationToken) ) { if (prefix == null) { throw new ArgumentNullException("Required property 'Prefix' for QueryPosesByPrefix module was not specified.", nameof(prefix)); } var containerTrace = await worldViewService.ResolvePath(folderPath); var jointValuesQuery = new ElementQuery { ContainerTrace = containerTrace, Recursive = recursive }; var jointValues = await worldViewService.QueryJointValues(jointValuesQuery); IList <JointValues> targetJointValues = jointValues .Where(x => x.DisplayName.StartsWith(prefix)) .OrderBy(x => x.DisplayName) .Select(x => x.Value.ToJointValues()) .ToList(); return(Tuple.Create(targetJointValues, targetJointValues.Count)); }
private async Task <IVisualElement> GetElement(string query, Type?desiredType) { ElementQuery elementQuery = GetFindElementQuery(query); LogMessage?.Invoke($"{nameof(GetElement)}({query})"); if (await Client.GetElementAsync(elementQuery) is { } reply) { if (reply.ErrorMessages.Any()) { throw new XAMLTestException(string.Join(Environment.NewLine, reply.ErrorMessages)); } if (reply.Elements.Count == 1) { Element element = reply.Elements[0]; if (Type.GetType(element.Type) is { } elementType) { if (desiredType is null) { return(Create(Client, element.Id, elementType, Serializer, LogMessage)); } if (desiredType != elementType && !elementType.IsSubclassOf(desiredType)) { throw new XAMLTestException($"Element of type '{element.Type}' does not match desired type '{desiredType.AssemblyQualifiedName}'"); } return(Create(Client, element.Id, desiredType, Serializer, LogMessage)); } throw new XAMLTestException($"Could not find element type '{element.Type}'"); } throw new XAMLTestException($"Found {reply.Elements.Count} elements"); } throw new XAMLTestException("Failed to receive a reply"); }
public string ExecuteQuery(ElementQuery query) { ElementInstance result = Elements.Where(el => el.Definition.Name == query.FromStatement && el.GetAttributeValue(query.WhereStatement) == query.EqualsStatement).FirstOrDefault(); if (result != null) { return(result.GetAttributeValue(query.SelectStatement)); } return(""); }
public UiElement FindElement(ElementQuery query) { var elements = FindElements(query); if (elements != null && elements.Any()) { return(elements.FirstOrDefault()); } return(null); }
public void TestVisitOnePathZeroMatch() { var sut = new ElementQuery("Patient.name"); var testPatient = new Patient(); var result = new List <object>(); sut.Visit(testPatient, fd => result.Add(fd)); Assert.Equal(testPatient.Name.Count, result.Where(ob => ob != null).Count()); }
public override bool Execute(ActivityContext context) { var query = ElementQuery.Get(this.Element); var elements = WinContext.Shared.GetElementsFromQuery(query); if (elements.Count() == 0) { return(false); } return(true); }
public async static Task <IList <CollisionObject> > QueryCollisionObjects( [InputPin(PropertyMode = PropertyMode.Default)] string folderPath, [InputPin(PropertyMode = PropertyMode.Default)] bool recursive = false ) { var trace = await worldViewService.ResolvePath(folderPath, WorldViewElementType.Folder); var query = new ElementQuery(); query.ContainerTrace = trace; query.Recursive = recursive; var response = await worldViewService.QueryCollisionObjects(query); return((IList <CollisionObject>)response.Select(x => x.Value.ToCollisionObject()).ToArray()); }
public override bool Execute(ActivityContext context) { var query = ElementQuery.Get(this.Element); if (query == null) { throw new Exception("Input 'Element' is required."); } var elements = WinContext.Shared.GetElementsFromQuery(query); if (elements.Count() == 0) { return(false); } return(true); }
public void TestVisitOnePathOneMatch() { var sut = new ElementQuery("Patient.name"); var testPatient = new Patient(); var hn = new HumanName().WithGiven("Sjors").AndFamily("Jansen"); testPatient.Name = new List <HumanName> { hn }; var result = new List <object>(); sut.Visit(testPatient, fd => result.Add(fd)); Assert.Equal(testPatient.Name.Count, result.Count(ob => ob != null)); Assert.Contains(hn, result); }
public static IEnumerable <Uri> GetReferences(this Resource resource, string include) { ElementQuery query = new ElementQuery(include); var list = new List <Uri>(); query.Visit(resource, element => { if (element is ResourceReference) { Uri uri = (element as ResourceReference).Url; if (uri != null) { list.Add(uri); } } }); return(list.Where(u => u != null)); }
public async Task <IVisualElement> GetElement(string query) { ElementQuery elementQuery = GetFindElementQuery(query); if (await Client.GetElementAsync(elementQuery) is { } reply) { if (reply.ErrorMessages.Any()) { throw new Exception(string.Join(Environment.NewLine, reply.ErrorMessages)); } if (reply.ElementIds.Count == 1) { return(new VisualElement(Client, reply.ElementIds[0])); } throw new Exception($"Found {reply.ElementIds.Count} elements"); } throw new Exception("Failed to receive a reply"); }
public void TestVisitOnePathTwoMatches() { var sut = new ElementQuery("Patient.name"); var testPatient = new Patient(); var hn1 = new HumanName().WithGiven("A").AndFamily("B"); var hn2 = new HumanName().WithGiven("Y").AndFamily("Z"); testPatient.Name = new List <HumanName> { hn1, hn2 }; var result = new List <object>(); sut.Visit(testPatient, fd => result.Add(fd)); Assert.Equal(testPatient.Name.Count, result.Where(ob => ob != null).Count()); Assert.Contains(hn1, result); Assert.Contains(hn2, result); }
public override void Execute(ActivityContext context) { var query = ElementQuery.Get(this.Element); var elements = WinContext.Shared.GetElementsFromQuery(query); if (elements.Count() == 0) { throw new Exception("Element not found."); } if (elements.Count() > 1) { throw new Exception("Too many elements found."); } var e = elements.First() as WinElement; e.Focus(); context.Set(this.Value, e.Value); }
public static IEnumerable <string> GetReferences(this Resource resource, string path) { if (!isValidResourcePath(path, resource)) { return(Enumerable.Empty <string>()); } ElementQuery query = new ElementQuery(path); var list = new List <string>(); query.Visit(resource, element => { if (element is ResourceReference) { string reference = (element as ResourceReference).Reference; if (reference != null) { list.Add(reference); } } }); return(list); }
public static IEnumerable<string> GetReferences(this Resource resource, string path) { if (!isValidResourcePath(path, resource)) return Enumerable.Empty<string>(); ElementQuery query = new ElementQuery(path); var list = new List<string>(); query.Visit(resource, element => { if (element is ResourceReference) { string reference = (element as ResourceReference).Reference; if (reference != null) { list.Add(reference); } } }); return list; }
public UiElement[] Query(ElementQuery query) { return(_nativeDriver.Query(query)); }
public async Task HasNoItemsExpanderVisibility_ChangesVisibiliyOnExpander() { await using var recorder = new TestRecorder(App); var treeView = await LoadXaml <TreeView>(@" <TreeView> <TreeViewItem Header=""Item1"" /> <TreeViewItem Header=""Item2"" materialDesign:TreeViewAssist.HasNoItemsExpanderVisibility=""Hidden"" /> <TreeViewItem Header=""Item3"" materialDesign:TreeViewAssist.HasNoItemsExpanderVisibility=""Collapsed"" /> <TreeViewItem Header=""Item4"" materialDesign:TreeViewAssist.HasNoItemsExpanderVisibility=""Visible"" /> <TreeViewItem Header=""Item5""> <TreeViewItem Header=""Child"" /> </TreeViewItem> <TreeViewItem Header=""Item6"" materialDesign:TreeViewAssist.HasNoItemsExpanderVisibility=""Hidden""> <TreeViewItem Header=""Child"" /> </TreeViewItem> <TreeViewItem Header=""Item7"" materialDesign:TreeViewAssist.HasNoItemsExpanderVisibility=""Collapsed""> <TreeViewItem Header=""Child"" /> </TreeViewItem> <TreeViewItem Header=""Item8"" materialDesign:TreeViewAssist.HasNoItemsExpanderVisibility=""Visible""> <TreeViewItem Header=""Child"" /> </TreeViewItem> </TreeView>"); var expander = await GetExpanderForHeader("Item1"); Assert.Equal(Visibility.Hidden, await expander.GetVisibility()); expander = await GetExpanderForHeader("Item2"); Assert.Equal(Visibility.Hidden, await expander.GetVisibility()); expander = await GetExpanderForHeader("Item3"); Assert.Equal(Visibility.Collapsed, await expander.GetVisibility()); expander = await GetExpanderForHeader("Item4"); Assert.Equal(Visibility.Visible, await expander.GetVisibility()); expander = await GetExpanderForHeader("Item5"); Assert.Equal(Visibility.Visible, await expander.GetVisibility()); expander = await GetExpanderForHeader("Item6"); Assert.Equal(Visibility.Visible, await expander.GetVisibility()); expander = await GetExpanderForHeader("Item7"); Assert.Equal(Visibility.Visible, await expander.GetVisibility()); expander = await GetExpanderForHeader("Item8"); Assert.Equal(Visibility.Visible, await expander.GetVisibility()); recorder.Success(); async Task <IVisualElement <ToggleButton> > GetExpanderForHeader(string header) { var item = await treeView !.GetElement(ElementQuery.PropertyExpression <TreeViewItem>(x => x.Header, header)); return(await item.GetElement <ToggleButton>()); } }
public UiElement[] FindElements(ElementQuery query) { var element = _agent.Query(query); return(element); }
public UiElement[] Query(ElementQuery query) { throw new NotImplementedException( "Call ClientUnityDriver over tachyon."); }
public UiElement[] Query(ElementQuery query) { return(query.Search()); }