ClassVisualFind
VisualFind is used to search the Visual Tree of the Silverlight Application. It provides a rich set of API to do rich search.
Definition
Namespace:ArtOfTest.WebAii.Silverlight
Assembly:ArtOfTest.WebAii.dll
Syntax:
public sealed class VisualFind : TreeCrawler<FrameworkElement, XamlFindExpression, XamlFindClause>
Inheritance: objectTreeCrawler<FrameworkElement, XamlFindExpression, XamlFindClause>VisualFind
Inherited Members
Properties
OwnerApp
Gets the owner app of this Find object.
SearchRoot
Gets the Search Root for this FrameworkElement
Declaration
public override FrameworkElement SearchRoot { get; }
Property Value
Overrides
Strategy
Gets or sets the find strategy to use when searching for elements in the VisualTree
Declaration
public FindStrategy Strategy { get; set; }
Property Value
WaitOnElementsTimeout
Gets or sets the time out to use when Strategy=AlwaysWaitForElementsVisible
Methods
AllByAutomationId(string)
Finds all controls with a given automation id
Declaration
public IList<FrameworkElement> AllByAutomationId(string id)
Parameters
id
The id to search for
Returns
A list of all controls with the given id
AllByAutomationId(string, string)
Declaration
public IList<FrameworkElement> AllByAutomationId(string id, string controlType)
Parameters
id
controlType
Returns
AllByCustom(Predicate<FrameworkElement>)
Declaration
public IList<FrameworkElement> AllByCustom(Predicate<FrameworkElement> customLogic)
Parameters
customLogic
Returns
AllByExpression(XamlFindExpression)
Finds all the elements in the tree that match the find expression.
Declaration
public override IList<FrameworkElement> AllByExpression(XamlFindExpression expression)
Parameters
expression
The find expression.
Returns
A list of all elements that match the expression or an empty list if nothing is found.
Overrides
Remarks
Uses this.SearchRoot as the search root
AllByName(string)
Declaration
public IList<FrameworkElement> AllByName(string name)
Parameters
name
Returns
AllByName(string, string)
Declaration
public IList<FrameworkElement> AllByName(string name, string controlType)
Parameters
name
controlType
Returns
AllByTextContent(string)
Declaration
public IList<FrameworkElement> AllByTextContent(string textContent)
Parameters
textContent
Returns
AllByType(string)
Declaration
public IList<FrameworkElement> AllByType(string controlType)
Parameters
controlType
Returns
AllByType<T>()
Declaration
public IList<T> AllByType<T>() where T : IFrameworkElement
Returns
IList<T>
ByAutomationId(string)
Search the Visual Tree for an element with a certain automation ID
Declaration
public FrameworkElement ByAutomationId(string id)
Parameters
id
The automation ID to search for
Returns
The first visual element with the specified automation ID
ByAutomationId(string, bool)
Declaration
public FrameworkElement ByAutomationId(string id, bool includeRoot)
Parameters
id
includeRoot
Returns
ByAutomationId<T>(string)
Search the Visual Tree for an element with a certain automation ID and return it as a strongly-typed control
Declaration
public T ByAutomationId<T>(string id) where T : IFrameworkElement
Parameters
id
The automation ID to search for
Returns
T
The first visual element with the specified automation ID, cast to the specified type
Remarks
This method does not limit the scope of its search only to controls whose types match T. It searches all controls, and attempts to cast the first match to type T.
ByBaseType<T>()
Finds the first element of type or null if no element is matching the criteria. If interface type searches for all types inheriting the specified one. Else, behaves like standard ByType method.
Declaration
public T ByBaseType<T>() where T : IFrameworkElement
Returns
T
The element if found, or null.
ByCustom(Predicate<FrameworkElement>)
Find using custom logic.
Declaration
public FrameworkElement ByCustom(Predicate<FrameworkElement> customLogic)
Parameters
customLogic
Custom logic predicate
Returns
The found element else null.
ByExpression(XamlFindExpression, bool)
Finds the first element in the tree that matches the find expression. It doesn't wait an element to be populated, returns immediately.
Declaration
public override FrameworkElement ByExpression(XamlFindExpression expression, bool includeRoot)
Parameters
expression
The find expression.
includeRoot
Whether to include the root node in the search
Returns
The first element it finds else null.
Overrides
ByExpressionReturnOrThrow(XamlFindExpression)
Finds the first element in the tree that matches the find expression. It respects the find strategy so can wait an element to be populated according to the timeout.
Declaration
public FrameworkElement ByExpressionReturnOrThrow(XamlFindExpression expression)
Parameters
expression
The find expression.
Returns
The first element it finds.
ByExpressionReturnOrThrow(XamlFindExpression, bool)
Finds the first element in the tree that matches the find expression. It respects the find strategy so can wait an element to be populated according to the timeout.
Declaration
public FrameworkElement ByExpressionReturnOrThrow(XamlFindExpression expression, bool includeRoot)
Parameters
expression
The find expression.
includeRoot
Whether to include the root node in the search
Returns
The first element it finds.
ByName(string)
Search the Visual Tree with an element with a certain name.
Declaration
public FrameworkElement ByName(string name)
Parameters
name
The name to find.
Returns
The first visual element with the specified name
ByName<T>(string)
Return the element with specified name as the desired type.
Declaration
public T ByName<T>(string name) where T : IFrameworkElement
Parameters
name
The element's name.
Returns
T
The object if found.
ByTextContent(string)
Return the element that contain the specified text.
Declaration
public FrameworkElement ByTextContent(string textContent)
Parameters
textContent
The text to look for. By default, we will use exact text, if you wish to use partial text then prefix the text with a '~' example: ByTextContent("~partialText")
Returns
The found element.
Remarks
The method respects all special characters. Check the ArtOfTest.Common.FindSpecialChars enumeration.
ByType(string)
Find the first control of type defined
Declaration
public FrameworkElement ByType(string controlType)
Parameters
controlType
The control type defined
Returns
The found control or null if not found
ByType<T>()
Find the first control of certain type.
Declaration
public T ByType<T>() where T : IFrameworkElement
Returns
T
The control or null if not found.
FindAllUsingHierarchicalClause(FrameworkElement, XamlFindClause)
Find all nodes using a hierarchical clause (XPATH, TagIndex...etc)
Declaration
public override IEnumerable<FrameworkElement> FindAllUsingHierarchicalClause(FrameworkElement startNode, XamlFindClause clause)
Parameters
startNode
The node to start with.
clause
The clause to use
Returns
The found elements else null;
Overrides
FindUsingHierarchicalClause(FrameworkElement, XamlFindClause)
Find a node using a hierarchical clause (XPATH, TagIndex...etc)
Declaration
public override FrameworkElement FindUsingHierarchicalClause(FrameworkElement startNode, XamlFindClause clause)
Parameters
startNode
The node to start with.
clause
The clause to use
Returns
The found element else null;
Overrides
RefreshRoot()
Refresh the visual tree this VisualFind object searches
Declaration
public void RefreshRoot()