public virtual Window CreateWindow(SearchCriteria searchCriteria, Process process, InitializeOption option, WindowSession windowSession) { string message = string.Format("Couldn't find window with SearchCriteria {0} in process {1}{2}", searchCriteria, process.Id, Constants.BusyMessage); AutomationElement element = WaitTillFound(() => finder.FindWindow(searchCriteria, process.Id), message); return Create(element, option, windowSession); }
public virtual IUIItem Create(SearchCriteria searchCriteria, ActionListener actionListener) { if (searchCriteria.IsIndexed) { UIItemCollection collection = CreateAll(searchCriteria, actionListener); return searchCriteria.IndexedItem(collection); } return dictionaryMappedItemFactory.Create(Finder.Descendant(searchCriteria.AutomationCondition), actionListener, searchCriteria.CustomItemType); }
public virtual IUIItem Get(SearchCriteria searchCriteria, ActionListener 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); }
public UIItemInterceptor(SearchCriteria searchCriteria, Window window,IReport sessionReport) { this.searchCriteria = searchCriteria; this.window = window; this.sessionReport = sessionReport; }
internal static SearchCriteria ForMenuBar(WindowsFramework framework) { var searchCriteria = new SearchCriteria(SearchConditionFactory.CreateForControlType(typeof (MenuBar), framework)); return searchCriteria.NotIdentifiedByText("System Menu Bar"); }
//TODO: Position based find should understand MdiChild /// <summary> /// Returns a UIItemContainer using which other sub-ui items can be retrieved. /// Since there is no single standard identification for MdiChild windows, hence it is has been left open for user. /// </summary> /// <param name="searchCriteria"></param> /// <returns></returns> public virtual UIItemContainer MdiChild(SearchCriteria searchCriteria) { var finder = new AutomationElementFinder(automationElement); AutomationElement element = finder.Descendant(searchCriteria.AutomationCondition); return element == null ? null : new UIItemContainer(element, this, InitializeOption.NoCache, windowSession); }
public virtual Window FindModalWindow(SearchCriteria searchCriteria, InitializeOption option, AutomationElement parentWindowElement, WindowSession windowSession) { var windowFinder = new AutomationElementFinder(parentWindowElement); try { AutomationElement modalWindowElement = WaitTillFound(delegate { AutomationElement windowElement = windowFinder.FindWindow(searchCriteria) ?? finder.FindWindow(searchCriteria); return windowElement; }, "Could not find modal window with SearchCriteria: " + searchCriteria); return Create(modalWindowElement, option, windowSession); } catch (UIActionException e) { WhiteLogger.Instance.Debug(e.ToString()); return null; } }
public virtual bool Has(SearchCriteria criteria) { return criteria.Equals(searchCriteria); }
public override Window ModalWindow(SearchCriteria searchCriteria, InitializeOption option) { return null; }
public override void Apply(SearchCriteria searchCriteria) { searchCriteria.AndIndex(index); }
public override void Add(Point point, SearchCriteria searchCriteria) { }
private IUIItem Create(ContainerItemFactory containerItemFactory, SearchCriteria searchCriteria, ActionListener actionListener) { IUIItem item = containerItemFactory.Get(searchCriteria, actionListener); if (item == null) return null; windowItemsMap.Add(item.Location, searchCriteria); return item; }
/// <summary> /// Uses the Raw View provided by UIAutomation to find elements within this UIItem. RawView sometimes contains extra AutomationElements. This is internal to /// white although made public. Should be used only if the standard approaches dont work. Also if you end up using it please raise an issue /// so that it can be fixed. /// Please understand that calling this method on any UIItem which has a lot of child AutomationElements might result in very bad performance. /// </summary> /// <param name="searchCriteria"></param> /// <returns>null or found AutomationElement</returns> public virtual AutomationElement GetElement(SearchCriteria searchCriteria) { return new AutomationElementFinder(automationElement).FindDescendantRaw( searchCriteria.AutomationSearchCondition); }
/// <summary> /// Get the modal window launched by this window with NoCache initialize option /// </summary> /// <param name="searchCriteria">Search Criteria to use to find a window</param> /// <returns></returns> public virtual Window ModalWindow(SearchCriteria searchCriteria) { return ModalWindow(searchCriteria, InitializeOption.NoCache); }
/// <summary> /// Get the modal window launched by this window. /// </summary> /// <param name="searchCriteria">Search Criteria to use to find a window</param> /// <param name="option">Newly created window would be initialized using this option</param> /// <returns></returns> public abstract Window ModalWindow(SearchCriteria searchCriteria, InitializeOption option);
public override IUIItem Get(ContainerItemFactory containerItemFactory, SearchCriteria searchCriteria, ActionListener actionListener) { return containerItemFactory.Get(searchCriteria, actionListener); }
public override Point GetItemLocation(SearchCriteria searchCriteria) { return RectX.UnlikelyWindowPosition; }
public virtual Window ModalWindow(SearchCriteria searchCriteria, InitializeOption option, WindowSession windowSession) { return ModalWindow(() => Finder.FindWindow(searchCriteria), option, windowSession); }
public abstract void Apply(SearchCriteria searchCriteria);
/// <summary> /// Get a child menu based on any search criteria. Use SubMenu(string) for searching based on visible text /// </summary> /// <param name="searchCriteria">Search criteria for the child menu</param> /// <returns></returns> public virtual Menu SubMenu(SearchCriteria searchCriteria) { return ChildMenus.Find(searchCriteria); }
public static SearchCriteria ByControlType(Type testControlType, WindowsFramework framework) { var searchCriteria = new SearchCriteria(SearchConditionFactory.CreateForControlType(testControlType, framework)); searchCriteria.InferCustomItemType(testControlType); return searchCriteria; }
public UIItemLocation(Point point, SearchCriteria searchCriteria) { this.point = point; this.searchCriteria = searchCriteria; }
public virtual UIItemCollection CreateAll(SearchCriteria searchCriteria, ActionListener actionListener) { return new UIItemCollection(Finder.Descendants(searchCriteria.AutomationSearchCondition), actionListener, searchCriteria.CustomItemType); }
public override void Apply(SearchCriteria searchCriteria) { searchCriteria.AndAutomationId(name); }
protected override IUIItem Find(SearchCriteria searchCriteria) { return children.Get(searchCriteria, actionListener); }
/// <summary> /// Create criteria with specified index /// </summary> /// <param name="zeroBasedIndex"></param> /// <returns></returns> public static SearchCriteria Indexed(int zeroBasedIndex) { var indexCondition = new IndexCondition(zeroBasedIndex); var criteria = new SearchCriteria(indexCondition); return criteria; }
public override Window ModalWindow(SearchCriteria searchCriteria, InitializeOption option) { WindowFactory desktopWindowsFactory = WindowFactory.Desktop; return desktopWindowsFactory.FindModalWindow(searchCriteria, option, automationElement, WindowSession.ModalWindowSession(option)); }
public virtual Window ModalWindow(SearchCriteria searchCriteria, InitializeOption option, WindowSession windowSession) { Clock.Do @do = () => finder.FindWindow(searchCriteria); return ModalWindow(@do, option, windowSession); }
public virtual SearchCriteria Merge(SearchCriteria other) { foreach (var searchCondition in other.conditions) { if (!conditions.Any(condition => condition.OfSameType(searchCondition))) { conditions.Add(searchCondition); } } return this; }