Class
VisualFind

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:

cs-api-definition
public sealed class VisualFind : TreeCrawler<FrameworkElement, XamlFindExpression, XamlFindClause>

Inheritance: objectTreeCrawler<FrameworkElement, XamlFindExpression, XamlFindClause>VisualFind

Inherited Members TreeCrawler<FrameworkElement, XamlFindExpression, XamlFindClause>.ByExpression(FrameworkElement, XamlFindExpression)TreeCrawler<FrameworkElement, XamlFindExpression, XamlFindClause>.ByExpression(XamlFindExpression)TreeCrawler<FrameworkElement, XamlFindExpression, XamlFindClause>.ByExpression(XamlFindExpression, bool)TreeCrawler<FrameworkElement, XamlFindExpression, XamlFindClause>.AllByExpression(XamlFindExpression)TreeCrawler<FrameworkElement, XamlFindExpression, XamlFindClause>.ByExpression(FrameworkElement, XamlFindExpression, bool)TreeCrawler<FrameworkElement, XamlFindExpression, XamlFindClause>.AllByExpression(FrameworkElement, XamlFindExpression)TreeCrawler<FrameworkElement, XamlFindExpression, XamlFindClause>.FindUsingHierarchicalClause(FrameworkElement, XamlFindClause)TreeCrawler<FrameworkElement, XamlFindExpression, XamlFindClause>.FindAllUsingHierarchicalClause(FrameworkElement, XamlFindClause)TreeCrawler<FrameworkElement, XamlFindExpression, XamlFindClause>.ByCustom(FrameworkElement, Predicate<FrameworkElement>, bool)TreeCrawler<FrameworkElement, XamlFindExpression, XamlFindClause>.AllByCustom(FrameworkElement, Predicate<FrameworkElement>, bool)TreeCrawler<FrameworkElement, XamlFindExpression, XamlFindClause>.FindUsingExpressionPath(FrameworkElement, string, out FrameworkElement)TreeCrawler<FrameworkElement, XamlFindExpression, XamlFindClause>.LastUsedExpressionTreeCrawler<FrameworkElement, XamlFindExpression, XamlFindClause>.SearchRoot

Properties

OwnerApp

Gets the owner app of this Find object.

Declaration

cs-api-definition
public IApplication OwnerApp { get; }

Property Value

IApplication

SearchRoot

Gets the Search Root for this FrameworkElement

Declaration

cs-api-definition
public override FrameworkElement SearchRoot { get; }

Property Value

FrameworkElement

Overrides TreeCrawler<FrameworkElement, XamlFindExpression, XamlFindClause>.SearchRoot

Strategy

Gets or sets the find strategy to use when searching for elements in the VisualTree

Declaration

cs-api-definition
public FindStrategy Strategy { get; set; }

Property Value

FindStrategy

WaitOnElementsTimeout

Gets or sets the time out to use when Strategy=AlwaysWaitForElementsVisible

Declaration

cs-api-definition
public int WaitOnElementsTimeout { get; set; }

Property Value

int

Methods

AllByAutomationId(string)

Finds all controls with a given automation id

Declaration

cs-api-definition
public IList<FrameworkElement> AllByAutomationId(string id)

Parameters

id

string

The id to search for

Returns

IList<FrameworkElement>

A list of all controls with the given id

AllByAutomationId(string, string)

Declaration

cs-api-definition
public IList<FrameworkElement> AllByAutomationId(string id, string controlType)

Parameters

id

string

controlType

string

Returns

IList<FrameworkElement>

AllByAutomationId<T>(string)

Declaration

cs-api-definition
public IList<T> AllByAutomationId<T>(string id) where T : IFrameworkElement

Parameters

id

string

Returns

IList<T>

AllByCustom(Predicate<FrameworkElement>)

Declaration

cs-api-definition
public IList<FrameworkElement> AllByCustom(Predicate<FrameworkElement> customLogic)

Parameters

customLogic

Predicate<FrameworkElement>

Returns

IList<FrameworkElement>

AllByExpression(XamlFindExpression)

Finds all the elements in the tree that match the find expression.

Declaration

cs-api-definition
public override IList<FrameworkElement> AllByExpression(XamlFindExpression expression)

Parameters

expression

XamlFindExpression

The find expression.

Returns

IList<FrameworkElement>

A list of all elements that match the expression or an empty list if nothing is found.

Overrides TreeCrawler<FrameworkElement, XamlFindExpression, XamlFindClause>.AllByExpression(XamlFindExpression)

Remarks

Uses this.SearchRoot as the search root

AllByName(string)

Declaration

cs-api-definition
public IList<FrameworkElement> AllByName(string name)

Parameters

name

string

Returns

IList<FrameworkElement>

AllByName(string, string)

Declaration

cs-api-definition
public IList<FrameworkElement> AllByName(string name, string controlType)

Parameters

name

string

controlType

string

Returns

IList<FrameworkElement>

AllByName<T>(string)

Declaration

cs-api-definition
public IList<T> AllByName<T>(string name) where T : IFrameworkElement

Parameters

name

string

Returns

IList<T>

AllByTextContent(string)

Declaration

cs-api-definition
public IList<FrameworkElement> AllByTextContent(string textContent)

Parameters

textContent

string

Returns

IList<FrameworkElement>

AllByType(string)

Declaration

cs-api-definition
public IList<FrameworkElement> AllByType(string controlType)

Parameters

controlType

string

Returns

IList<FrameworkElement>

AllByType<T>()

Declaration

cs-api-definition
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

cs-api-definition
public FrameworkElement ByAutomationId(string id)

Parameters

id

string

The automation ID to search for

Returns

FrameworkElement

The first visual element with the specified automation ID

ByAutomationId(string, bool)

Declaration

cs-api-definition
public FrameworkElement ByAutomationId(string id, bool includeRoot)

Parameters

id

string

includeRoot

bool

Returns

FrameworkElement

ByAutomationId<T>(string)

Search the Visual Tree for an element with a certain automation ID and return it as a strongly-typed control

Declaration

cs-api-definition
public T ByAutomationId<T>(string id) where T : IFrameworkElement

Parameters

id

string

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

cs-api-definition
public T ByBaseType<T>() where T : IFrameworkElement

Returns

T

The element if found, or null.

ByCustom(Predicate<FrameworkElement>)

Find using custom logic.

Declaration

cs-api-definition
public FrameworkElement ByCustom(Predicate<FrameworkElement> customLogic)

Parameters

customLogic

Predicate<FrameworkElement>

Custom logic predicate

Returns

FrameworkElement

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

cs-api-definition
public override FrameworkElement ByExpression(XamlFindExpression expression, bool includeRoot)

Parameters

expression

XamlFindExpression

The find expression.

includeRoot

bool

Whether to include the root node in the search

Returns

FrameworkElement

The first element it finds else null.

Overrides TreeCrawler<FrameworkElement, XamlFindExpression, XamlFindClause>.ByExpression(XamlFindExpression, bool)

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

cs-api-definition
public FrameworkElement ByExpressionReturnOrThrow(XamlFindExpression expression)

Parameters

expression

XamlFindExpression

The find expression.

Returns

FrameworkElement

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

cs-api-definition
public FrameworkElement ByExpressionReturnOrThrow(XamlFindExpression expression, bool includeRoot)

Parameters

expression

XamlFindExpression

The find expression.

includeRoot

bool

Whether to include the root node in the search

Returns

FrameworkElement

The first element it finds.

ByName(string)

Search the Visual Tree with an element with a certain name.

Declaration

cs-api-definition
public FrameworkElement ByName(string name)

Parameters

name

string

The name to find.

Returns

FrameworkElement

The first visual element with the specified name

ByName<T>(string)

Return the element with specified name as the desired type.

Declaration

cs-api-definition
public T ByName<T>(string name) where T : IFrameworkElement

Parameters

name

string

The element's name.

Returns

T

The object if found.

ByTextContent(string)

Return the element that contain the specified text.

Declaration

cs-api-definition
public FrameworkElement ByTextContent(string textContent)

Parameters

textContent

string

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

FrameworkElement

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

cs-api-definition
public FrameworkElement ByType(string controlType)

Parameters

controlType

string

The control type defined

Returns

FrameworkElement

The found control or null if not found

ByType<T>()

Find the first control of certain type.

Declaration

cs-api-definition
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

cs-api-definition
public override IEnumerable<FrameworkElement> FindAllUsingHierarchicalClause(FrameworkElement startNode, XamlFindClause clause)

Parameters

startNode

FrameworkElement

The node to start with.

clause

XamlFindClause

The clause to use

Returns

IEnumerable<FrameworkElement>

The found elements else null;

Overrides TreeCrawler<FrameworkElement, XamlFindExpression, XamlFindClause>.FindAllUsingHierarchicalClause(FrameworkElement, XamlFindClause)

FindUsingHierarchicalClause(FrameworkElement, XamlFindClause)

Find a node using a hierarchical clause (XPATH, TagIndex...etc)

Declaration

cs-api-definition
public override FrameworkElement FindUsingHierarchicalClause(FrameworkElement startNode, XamlFindClause clause)

Parameters

startNode

FrameworkElement

The node to start with.

clause

XamlFindClause

The clause to use

Returns

FrameworkElement

The found element else null;

Overrides TreeCrawler<FrameworkElement, XamlFindExpression, XamlFindClause>.FindUsingHierarchicalClause(FrameworkElement, XamlFindClause)

RefreshRoot()

Refresh the visual tree this VisualFind object searches

Declaration

cs-api-definition
public void RefreshRoot()