diff --git a/src/TestStack.White/UIItems/UIItemContainer.cs b/src/TestStack.White/UIItems/UIItemContainer.cs index 11239d8e..61fd0dec 100644 --- a/src/TestStack.White/UIItems/UIItemContainer.cs +++ b/src/TestStack.White/UIItems/UIItemContainer.cs @@ -65,6 +65,35 @@ public virtual IUIItem Get(SearchCriteria searchCriteria) return Get(searchCriteria, CoreAppXmlConfiguration.Instance.BusyTimeout()); } + public virtual bool Exists() where T : IUIItem + { + return Exists(SearchCriteria.All); + } + + public virtual bool Exists(string primaryIdentification) where T : IUIItem + { + return Exists(SearchCriteria.ByAutomationId(primaryIdentification)); + } + + public virtual bool Exists(SearchCriteria searchCriteria) where T : IUIItem + { + return Exists(searchCriteria.AndControlType(typeof(T), Framework)); + } + + public virtual bool Exists(SearchCriteria searchCriteria) + { + try + { + Get(searchCriteria, TimeSpan.FromMilliseconds(0)); + return true; + } + catch (AutomationException) + { + return false; + } + + } + /// /// Finds UIItem which matches specified type and searchCriteria. Look at documentation of SearchCriteria for details on it. ///