Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue183: Add Exists<>() method. #189

Merged
merged 3 commits into from
Jan 16, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/TestStack.White/UIItems/UIItemContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,35 @@ public virtual IUIItem Get(SearchCriteria searchCriteria)
return Get(searchCriteria, CoreAppXmlConfiguration.Instance.BusyTimeout());
}

public virtual bool Exists<T>() where T : IUIItem
{
return Exists<T>(SearchCriteria.All);
}

public virtual bool Exists<T>(string primaryIdentification) where T : IUIItem
{
return Exists<T>(SearchCriteria.ByAutomationId(primaryIdentification));
}

public virtual bool Exists<T>(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;
}

}

/// <summary>
/// Finds UIItem which matches specified type and searchCriteria. Look at documentation of SearchCriteria for details on it.
/// </summary>
Expand Down