public static T GetParent <T>(this IUIItem thisItem) where T : IUIItem { var parent = Desktop.Automation.TreeWalkerFactory.GetControlViewWalker().GetParent(thisItem.AutomationElement); var uiItem = ItemFactory.Create(parent, thisItem.ActionListener); return((T)UIItemProxyFactory.Create(uiItem, uiItem.ActionListener)); }
public virtual IUIItem Get(SearchCriteria searchCriteria, IActionListener uiItemActionListener) { IUIItem item = Find(searchCriteria); if (item == null || item is UIItemContainer) { //Cannot create dynamic proxy for class which has methods using generics. Also its not required to intercept methods on UIItem containers return(item); } return(UIItemProxyFactory.Create(item, uiItemActionListener)); }
public virtual IUIItem Get(ContainerItemFactory containerItemFactory, SearchCriteria searchCriteria, ActionListener actionListener) { WhiteLogger.Instance.DebugFormat("Finding item based on criteria: ({0}) on ({1})", searchCriteria, initializeOption.Identifier); Point location = windowItemsMap.GetItemLocation(searchCriteria); if (location.Equals(RectX.UnlikelyWindowPosition)) { WhiteLogger.Instance.Debug("[PositionBasedSearch] Could not find based on position, finding using search."); return(Create(containerItemFactory, searchCriteria, actionListener)); } AutomationElement automationElement = AutomationElementX.GetAutomationElementFromPoint(location); if (automationElement != null && searchCriteria.AppliesTo(automationElement)) { IUIItem item = new DictionaryMappedItemFactory().Create(automationElement, actionListener, searchCriteria.CustomItemType); return(UIItemProxyFactory.Create(item, actionListener)); } WhiteLogger.Instance.DebugFormat("[PositionBasedSearch] UIItem {0} changed its position, finding using search.", searchCriteria); return(Create(containerItemFactory, searchCriteria, actionListener)); }