Class
Find

Class provides quick search routines for finding an element(s) within a document.

Definition

Namespace:ArtOfTest.WebAii.Core

Assembly:ArtOfTest.WebAii.dll

Syntax:

cs-api-definition
public class Find

Inheritance: objectFind

Derived Classes: HtmlFind

Properties

AssociatedBrowser

Gets the browser object that is associated with this find object. If this property is null, then the Find object is associated with a search region.

Declaration

cs-api-definition
public Browser AssociatedBrowser { get; }

Property Value

Browser

Remarks

Either Find.SearchRegion or Find.AssociatedBrowser is null. Both can't be null and both can't be set.

FindReferenceType

Gets the reference type that this Find object is using. (i.e. browser root, testregion ... etc)

Declaration

cs-api-definition
public FindReferenceType FindReferenceType { get; }

Property Value

FindReferenceType

IgnoreFindAllControlMismatch

Gets/Sets whether to ignore Find.Allxx<TControl>(...) elements that don't match the TControl specified. (i.e. the TControl type validation fails for that element). If false, the Find.Allxx method will throw an exception.

Declaration

cs-api-definition
public bool IgnoreFindAllControlMismatch { get; set; }

Property Value

bool

LastFindParam

Gets the last FindParam used to search.

Declaration

cs-api-definition
public FindParam LastFindParam { get; }

Property Value

FindParam

LastSearchLog

Gets the search log for the last find attempt. This log can help diagnose when find fails to locate an element.

Declaration

cs-api-definition
public string LastSearchLog { get; }

Property Value

string

SearchRegion

Gets the search region for this Find object. When this is set to a specific region, all search is done locale to that region. All indexes are calculated starting at zero from this region's element. If this property is null, then the Find object will perform all searches from the document root element.

Declaration

cs-api-definition
public TestRegion SearchRegion { get; }

Property Value

TestRegion

SearchRootElement

Gets/Sets the root element that all searches will be performed under. This element depended on the reference type. [Browser/TestRegion/Element].

Declaration

cs-api-definition
public Element SearchRootElement { get; }

Property Value

Element

ThrowIfNullOrEmpty

Gets/Sets whether to throw an exception if any of the find methods returns a null element or any of the find all methods return empty list of elements.

Declaration

cs-api-definition
public bool ThrowIfNullOrEmpty { get; set; }

Property Value

bool

Methods

AllByAttributes(params string[])

Returns a list of elements that have attributes that match the NameValuePairs passed it fully or partially.

Declaration

cs-api-definition
public ReadOnlyCollection<Element> AllByAttributes(params string[] nameValuePairs)

Parameters

nameValuePairs

string[]

A list of name value pairs to match. For example: "bar=foo","class=myclass","src=foo.gif","src=!bar". Use = for partial values or =! to exclude values.

Returns

ReadOnlyCollection<Element>

The list of found elements.

AllByAttributes<TControl>(params string[])

Returns a list of elements that have attributes that match the NameValuePairs passed it fully or partially.

Declaration

cs-api-definition
public ReadOnlyCollection<TControl> AllByAttributes<TControl>(params string[] nameValuePairs) where TControl : Control, new()

Parameters

nameValuePairs

string[]

A list of name value pairs to match. For example: AllByAttributes("bar=foo","class=myclass","src=foo.gif"). Use = for partial values.

Returns

ReadOnlyCollection<TControl>

The list of found elements.

Remarks

If

AllByContent(string)

Returns a list of elements that have TextContent that match the specified content The content must start with: 'l:' for exact match strings, 'p:' for partial strings or 'x:' for regular expression matches. If none are provided, the string will be matched using an exact match 'l:'. All searches are case-insensitive.

To find tags with TextContent of: 'foo bar' Example 1: ByContent("l:foo bar"); Example 2: ByContent("p:foo"); Example 3: ByContent("x:[*foo*]"); There is a difference between FindContentType.InnerText and FindContentType.TextContent that is worth noting:

Example:

Text1
Text2

InnerText for div1 : Text1Text2 {recursive} TextContent of div1 : Text1 {non-recursive}

Default for ByContent is TextContent which is the most common usage.

Declaration

cs-api-definition
public ReadOnlyCollection<Element> AllByContent(string textContent)

Parameters

textContent

string

The TextContent to match

Returns

ReadOnlyCollection<Element>

The list of found elements.

AllByContent(string, FindContentType)

Returns a list of elements that match the specified content. The content must start with: 'l:' for exact match strings, 'p:' for partial strings or 'x:' for regular expression matches. If none are provided, the string will be matched using an exact match 'l:'. All searches are case-insensitive.

To find tags with TextContent of: 'foo bar' Example 1: ByContent("l:foo bar"); Example 2: ByContent("p:foo"); Example 3: ByContent("x:[*foo*]"); There is a difference between FindContentType.InnerText and FindContentType.TextContent that is worth noting:

Example:

Text1
Text2

InnerText for div1 : Text1Text2 {recursive} TextContent of div1 : Text1 {non-recursive}

Default for ByContent is TextContent which is the most common usage.

Declaration

cs-api-definition
public ReadOnlyCollection<Element> AllByContent(string content, FindContentType contentType)

Parameters

content

string

The content to match

contentType

FindContentType

The content type to match.

Returns

ReadOnlyCollection<Element>

The list of found elements.

AllByContent<TControl>(string)

Returns a list of elements that have TextContent that match the specified content The content must start with: 'l:' for exact match strings, 'p:' for partial strings or 'x:' for regular expression matches. If none are provided, the string will be matched using an exact match 'l:'. All searches are case-insensitive.

To find tags with TextContent of: 'foo bar' Example 1: ByContent("l:foo bar"); Example 2: ByContent("p:foo"); Example 3: ByContent("x:[*foo*]"); There is a difference between FindContentType.InnerText and FindContentType.TextContent that is worth noting:

Example:

Text1
Text2

InnerText for div1 : Text1Text2 {recursive} TextContent of div1 : Text1 {non-recursive}

Default for ByContent is TextContent which is the most common usage.

Declaration

cs-api-definition
public ReadOnlyCollection<TControl> AllByContent<TControl>(string textContent) where TControl : Control, new()

Parameters

textContent

string

The TextContent to match

Returns

ReadOnlyCollection<TControl>

The list of found controls (htmlControl for example).

AllByContent<TControl>(string, FindContentType)

Returns a list of elements that match the specified content. The content must start with: 'l:' for exact match strings, 'p:' for partial strings or 'x:' for regular expression matches. If none are provided, the string will be matched using an exact match 'l:'. All searches are case-insensitive.

To find tags with TextContent of: 'foo bar' Example 1: ByContent("l:foo bar"); Example 2: ByContent("p:foo"); Example 3: ByContent("x:[*foo*]"); There is a difference between FindContentType.InnerText and FindContentType.TextContent that is worth noting:

Example:

Text1
Text2

InnerText for div1 : Text1Text2 {recursive} TextContent of div1 : Text1 {non-recursive}

Default for ByContent is TextContent which is the most common usage.

Declaration

cs-api-definition
public ReadOnlyCollection<TControl> AllByContent<TControl>(string content, FindContentType contentType) where TControl : Control, new()

Parameters

content

string

The content to match

contentType

FindContentType

The content type to match.

Returns

ReadOnlyCollection<TControl>

The list of found controls (htmlControl for example).

AllByCssSelector(string)

Find all by css selector.

Declaration

cs-api-definition
public ReadOnlyCollection<Element> AllByCssSelector(string selector)

Parameters

selector

string

The css selector.

Returns

ReadOnlyCollection<Element>

AllByCssSelector<TControl>(string)

Find all by css selector.

Declaration

cs-api-definition
public ReadOnlyCollection<TControl> AllByCssSelector<TControl>(string selector) where TControl : Control, new()

Parameters

selector

string

The css selector.

Returns

ReadOnlyCollection<TControl>

AllByCustom(Predicate<Element>)

Return all elements that match the predicate

Declaration

cs-api-definition
public ReadOnlyCollection<Element> AllByCustom(Predicate<Element> predicate)

Parameters

predicate

Predicate<Element>

The custom predicate that defines the element search

Returns

ReadOnlyCollection<Element>

The list of elements that match the predicate, else an empty collection or an exception (depending on ThrowIfNullOrEmpty)

AllByCustom<TControl>(Predicate<TControl>)

Returns all controls that match the predicate and are convertable to TControl.

Declaration

cs-api-definition
public ReadOnlyCollection<TControl> AllByCustom<TControl>(Predicate<TControl> predicate) where TControl : Control, new()

Parameters

predicate

Predicate<TControl>

The predicate to use during the search.

Returns

ReadOnlyCollection<TControl>

A read only collection of elements matching the predicate and control type.

AllByExpression(HtmlFindExpression)

Find all elements by HtmlFindExpression.

Declaration

cs-api-definition
public ReadOnlyCollection<Element> AllByExpression(HtmlFindExpression expression)

Parameters

expression

HtmlFindExpression

The HtmlFindExpression to use during the find.

Returns

ReadOnlyCollection<Element>

A ReadOnlyCollection<T> of Element

AllByExpression(params string[])

Find all elements by HTML find expression strings.

Declaration

cs-api-definition
public ReadOnlyCollection<Element> AllByExpression(params string[] expression)

Parameters

expression

string[]

Array of HTML find expression strings.

Returns

ReadOnlyCollection<Element>

A ReadOnlyCollection<T> of elements.

AllByExpression<TControl>(HtmlFindExpression)

Find all elements by HtmlFindExpression of type TControl.

Declaration

cs-api-definition
public ReadOnlyCollection<TControl> AllByExpression<TControl>(HtmlFindExpression expression) where TControl : Control, new()

Parameters

expression

HtmlFindExpression

The HtmlFindExpression to use during the find.

Returns

ReadOnlyCollection<TControl>

A ReadOnlyCollection<T> of TControl elements.

AllByExpression<TControl>(params string[])

Find all elements by HTML find expression strings of type TControl.

Declaration

cs-api-definition
public ReadOnlyCollection<TControl> AllByExpression<TControl>(params string[] expression) where TControl : Control, new()

Parameters

expression

string[]

Array of HTML find expression strings.

Returns

ReadOnlyCollection<TControl>

A ReadOnlyCollection<T> of TControl elements.

AllByImage(Image, double, bool, Point, int, float, int)

Return all elements that look like specific image.

Declaration

cs-api-definition
public ReadOnlyCollection<Element> AllByImage(Image image, double score, bool autoScroll = true, Point probeOffset = default, int timeout = 2147483647, float imageScale = 1, int searchDelay = 100)

Parameters

image

Image

The image to search for.

score

double

The minimum matching score. Value must be between 0 and 100.

autoScroll

bool

If set to true will scroll the page under test. If set to false will search only the visible area.

probeOffset

Point

Probing offset. Offset from center of the image rectagle. If the element you are looking for is not in the center of provided image use this argument to specify where its center is (related to image center).

timeout

int

Timeout in milliseconds.

imageScale

float

The original screen scaling applied when the image was taken.

searchDelay

int

Number of ms to wait before searching for element image.

Returns

ReadOnlyCollection<Element>

All elements that match provided image. If an element is part of iframe will return iframe element.

AllByTagName(string)

Returns a list of elements with a specific tag name.

Declaration

cs-api-definition
public ReadOnlyCollection<Element> AllByTagName(string tagName)

Parameters

tagName

string

The tag name to search for.

Returns

ReadOnlyCollection<Element>

The list of found elements.

AllByTagName<TControl>(string)

Returns a list of elements with a specific tag name as a control collection.

Declaration

cs-api-definition
public ReadOnlyCollection<TControl> AllByTagName<TControl>(string tagName) where TControl : Control, new()

Parameters

tagName

string

The tag name.

Returns

ReadOnlyCollection<TControl>

The list of found controls.

AllByXPath(string)

Returns a list of elements that match the specified XPath. This function supports the System.Xml XPath syntax.

Declaration

cs-api-definition
public ReadOnlyCollection<Element> AllByXPath(string xpath)

Parameters

xpath

string

The XPath string. XPath is case-sensitive.

Returns

ReadOnlyCollection<Element>

The list of found elements.

AllByXPath<TControl>(string)

Returns a list of elements that match the specified XPath. This function supports the System.Xml XPath syntax.

Declaration

cs-api-definition
public ReadOnlyCollection<TControl> AllByXPath<TControl>(string xpath) where TControl : Control, new()

Parameters

xpath

string

The XPath string. XPath is case-sensitive.

Returns

ReadOnlyCollection<TControl>

The list of found elements.

AllControls<TControl>()

Gets an IEnmerable for TControl to be used for LINQ queries. This will return only elements that are convertable to TControl

Declaration

cs-api-definition
public IEnumerable<TControl> AllControls<TControl>() where TControl : Control, new()

Returns

IEnumerable<TControl>

IEnumberable

AllElements()

Gets a IEnumerable for all elements to be used for LINQ queries

Declaration

cs-api-definition
public IEnumerable<Element> AllElements()

Returns

IEnumerable<Element>

IEnumberable

BuildBestFitFindExpression(Element)

Generates a HtmlFindExpression to be used to find the specified element. The function uses an algorithm optimized for most reliable search methods and will revert back to using the tagname index as a last resort

Declaration

cs-api-definition
public static HtmlFindExpression BuildBestFitFindExpression(Element element)

Parameters

element

Element

The element to generate the find expression for.

Returns

HtmlFindExpression

The find expression to use to find the element. Can contain nested find expressions.

ByAttributes(params string[])

Returns a an element that has attributes that match the NameValuePairs passed it. All matching is case-insensitive.

Declaration

cs-api-definition
public Element ByAttributes(params string[] nameValuePairs)

Parameters

nameValuePairs

string[]

A list of name value pairs to match. For example: "bar=foo","class=myclass","src=foo.gif","src=!bar". Use = for partial values or =! to exclude values.

Returns

Element

The found element. The function returns null if no element is found.

ByAttributes<TControl>(params string[])

Same as ByAttributes(). Returns a control type instead of element.

Declaration

cs-api-definition
public TControl ByAttributes<TControl>(params string[] nameValuePairs) where TControl : Control, new()

Parameters

nameValuePairs

string[]

A list of name value pairs to match. For example: "bar=foo","class=myclass","src=foo.gif","src=!bar". Use = for partial values or =! to exclude values.

Returns

TControl

The control object.

ByContent(string)

Returns an element by searching its TextContent. The content must start with: 'l:' for exact match strings, 'p:' for partial strings or 'x:' for regular expression matches. If none are provided, the string will be matched using an exact match 'l:'. All searches are case-insensitive.

To find tags with innerText content is: 'foo bar' Example 1: ByContent("l:foo bar"); Example 2: ByContent("p:foo"); Example 3: ByContent("x:[*foo*]");

Declaration

cs-api-definition
public Element ByContent(string content)

Parameters

content

string

The content to match

Returns

Element

The found element. The function returns null if no element is found

ByContent(string, FindContentType)

Returns an element by searching its content with the options to pick the content type. (InnerText, InnerMarkup or OuterMarkup) The content must start with: 'l:' for exact match strings, 'p:' for partial strings or 'x:' for regular expression matches. If none are provided, the string will be matched using an exact match 'l:'. All searches are case-insensitive.

Similar to Find.ByContent(string) with the option to specify the content type: Example 1: ByContent("l:foo bar",FindContentType.InnerText); Example 2: ByContent("p:<foo id="f" />",FindContent.OuterMarkup); There is a difference between FindContentType.InnerText and FindContentType.TextContent that is worth noting:

Example:

Text1
Text2

InnerText for div1 : Text1Text2 {recursive} TextContent of div1 : Text1 {non-recursive}

Default for ByContent is TextContent which is the most common usage.

Declaration

cs-api-definition
public Element ByContent(string content, FindContentType contentType)

Parameters

content

string

The content to match.

contentType

FindContentType

The content type to match.

Returns

Element

The found element. The function returns null if no element is found

ByContent(string, FindContentType, params string[])

Returns an element by searching its content with the options to pick the content type. (InnerText, InnerMarkup or OuterMarkup) in addition to a list of attributes. The content must start with: 'l:' for exact match strings, 'p:' for partial strings or 'x:' for regular expression matches. If none are provided, the string will be matched using an exact match 'l:'. All searches are case-insensitive.

Similar to Find.ByContent(string) with the option to specify the content type: Example 1: ByContent("l:foo bar",FindContentType.InnerText); Example 2: ByContent("p:<foo id="f" />",FindContent.OuterMarkup); There is a difference between FindContentType.InnerText and FindContentType.TextContent that is worth noting:

Example:

Text1
Text2

InnerText for div1 : Text1Text2 {recursive} TextContent of div1 : Text1 {non-recursive}

Default for ByContent is TextContent which is the most common usage.

Declaration

cs-api-definition
public Element ByContent(string content, FindContentType contentType, params string[] nameValuePairs)

Parameters

content

string

The content to match.

contentType

FindContentType

The content type to match.

nameValuePairs

string[]

The attribute name/value pairs to apply.

Returns

Element

The found element. The function returns null if no element is found

ByContent<TControl>(string)

Same as ByContent(). Returns a control type instead of element.

Declaration

cs-api-definition
public TControl ByContent<TControl>(string content) where TControl : Control, new()

Parameters

content

string

The content to match

Returns

TControl

The control object.

ByContent<TControl>(string, FindContentType)

Same as ByContent(). Returns a control type instead of element.

Declaration

cs-api-definition
public TControl ByContent<TControl>(string content, FindContentType contentType) where TControl : Control, new()

Parameters

content

string

The content to match.

contentType

FindContentType

The content type to match.

Returns

TControl

The control object.

ByContent<TControl>(string, FindContentType, params string[])

Same as ByContent(). Returns a control type instead of element.

Declaration

cs-api-definition
public TControl ByContent<TControl>(string content, FindContentType contentType, params string[] nameValuePairs) where TControl : Control, new()

Parameters

content

string

The content to match.

contentType

FindContentType

The content type to match.

nameValuePairs

string[]

The attribute name/value pairs to apply.

Returns

TControl

The control object.

ByCssSelector(string)

Returns an element by searching using a css selector.

Declaration

cs-api-definition
public Element ByCssSelector(string selector)

Parameters

selector

string

The css selector.

Returns

Element

The found element.

Exceptions

FindException

Thrown if element is not found and ThrowIfNullOrEmpty is true.

ByCssSelector<TControl>(string)

Returns a control by searching using a css selector.

Declaration

cs-api-definition
public TControl ByCssSelector<TControl>(string selector) where TControl : Control, new()

Parameters

selector

string

The css selector.

Returns

TControl

The found control.

ByCustom(Predicate<Element>)

Return the element that matches the defined predicate.

Declaration

cs-api-definition
public Element ByCustom(Predicate<Element> predicate)

Parameters

predicate

Predicate<Element>

The custom predicate that defines the element search.

Returns

Element

The element, else null.

Exceptions

FindException

Thrown if the element was not found and ThrowIfNullOrEmpty is set.

ByCustom<TControl>(Predicate<TControl>)

Get a control by using custom predicate. This function will try to eliminate any elements that are not convertable to TControl type.

Declaration

cs-api-definition
public TControl ByCustom<TControl>(Predicate<TControl> predicate) where TControl : Control, new()

Parameters

predicate

Predicate<TControl>

The predicate.

Returns

TControl

The first found control.

ByExpression(HtmlFindExpression)

Find element by HtmlFindExpression.

Declaration

cs-api-definition
public Element ByExpression(HtmlFindExpression expression)

Parameters

expression

HtmlFindExpression

The HtmlFindExpression to use during the find.

Returns

Element

An Element if found or null if not found.

ByExpression(HtmlFindExpression, bool)

Declaration

cs-api-definition
public Element ByExpression(HtmlFindExpression expression, bool includeRoot)

Parameters

expression

HtmlFindExpression

The HtmlFindExpression to use during the find.

includeRoot

bool

Whether or not to include the root element in the search.

Returns

Element

An Element if found or null if not found.

ByExpression(params string[])

Find element by HTML find expression strings.

Declaration

cs-api-definition
public Element ByExpression(params string[] expression)

Parameters

expression

string[]

Array of HTML find expression strings.

Returns

Element

An Element if found or null if not found.

ByExpression<TControl>(HtmlFindExpression)

Find element by HtmlFindExpression of type TControl.

Declaration

cs-api-definition
public TControl ByExpression<TControl>(HtmlFindExpression expression) where TControl : Control, new()

Parameters

expression

HtmlFindExpression

The HtmlFindExpression to use during the find.

Returns

TControl

A TControl element if found or null if not found.

ByExpression<TControl>(params string[])

Find element by HTML find expression strings of type TControl.

Declaration

cs-api-definition
public TControl ByExpression<TControl>(params string[] expression) where TControl : Control, new()

Parameters

expression

string[]

Array of HTML find expression strings.

Returns

TControl

A TControl element if found or null if not found.

ById(string)

Returns an element by looking for its 'id' attribute value.

Declaration

cs-api-definition
public Element ById(string id)

Parameters

id

string

The id value for the element to find. All searches are case-insensitive. Prefix the id with '~' for partial id searches.

Returns

Element

The found element. The function returns null if no element is found.

ById<TControl>(string)

Same as ById(). Returns a control type instead of element.

Declaration

cs-api-definition
public TControl ById<TControl>(string id) where TControl : Control, new()

Parameters

id

string

The id value for the element to find. All searches are case-insensitive

Returns

TControl

The control object.

ByImage(Image, double, int, bool, Point, int, float, int)

Return an element that looks like specific image.

Declaration

cs-api-definition
public Element ByImage(Image image, double score, int index = 0, bool autoScroll = true, Point probeOffset = default, int timeout = 2147483647, float imageScale = 1, int searchDelay = 100)

Parameters

image

Image

The image to search for.

score

double

The minimum matching score. Value must be between 0 and 100.

index

int

The image index. This is a zero-base index.

autoScroll

bool

If set to true will scroll the page under test. If set to false will search only the visible area.

probeOffset

Point

Probing offset. Offset from center of the image rectagle. If the element you are looking for is not in the center of provided image use this argument to specify where its center is (related to image center).

timeout

int

Timeout in milliseconds.

imageScale

float

The original screen scaling applied when the image was taken.

searchDelay

int

Number of ms to wait before searching for element image.

Returns

Element

The element that matches provided image. If the element is part of iframe will return iframe element.

ByName(string)

Returns an element by searching for its 'name' attribute value

Declaration

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

Parameters

name

string

The name value for the element to find. All searches as case-insensitive

Returns

Element

The found element. The function returns null if no element is found.

ByName<TControl>(string)

Same as ByName(). Returns a control type instead of element.

Declaration

cs-api-definition
public TControl ByName<TControl>(string name) where TControl : Control, new()

Parameters

name

string

The name value for the element to find. All searches as case-insensitive

Returns

TControl

The control object.

ByNodeIndexPath(string)

Returns an element by searching for it using a node index path.

csharp
For example: 

This call: ByNodeIndexPath("0/2/0/1") describes the <target></target> element in the below hierarchy:

<referenceElement> (0)<foo> <bar> </bar> <car> </car> (2)<bus> (0)<driver> <cap> </cap> (1)<target> </target> </driver> </bus> </foo> </referenceElement>

Declaration

cs-api-definition
public Element ByNodeIndexPath(string nodeIndexPath)

Parameters

nodeIndexPath

string

The node index path. This is a forward slash delimited list of tree node indexes that describe a specific path to a target element while ignoring the actual element tags and simply describing the hierarchal relationship to that element.

Returns

Element

The found element. The function returns null if no element is found.

ByNodeIndexPath<TControl>(string)

Same as ByNodexIndexPath(). Returns a control type instead of element.

Declaration

cs-api-definition
public TControl ByNodeIndexPath<TControl>(string nodeIndexPath) where TControl : Control, new()

Parameters

nodeIndexPath

string

Node index path identifying the target element to wrap.

Returns

TControl

A control of the specified type.

Exceptions

NullReferenceException

Thrown no element at the node index path.

ByTagIndex(string, int)

Returns an element by its tag name occrrence.

Declaration

cs-api-definition
public Element ByTagIndex(string tagName, int occurrenceIndex)

Parameters

tagName

string

The tag name to find.

occurrenceIndex

int

The tag name index. This is a zero-base index.

Returns

Element

The found element. The function returns null if no element is found.

ByTagIndex<TControl>(string, int)

Same as ByTagIndex(). Returns a control type instead of element.

Declaration

cs-api-definition
public TControl ByTagIndex<TControl>(string tagName, int occurrenceIndex) where TControl : Control, new()

Parameters

tagName

string

The tag name to find.

occurrenceIndex

int

The tag name index. This is a zero-base index.

Returns

TControl

The control object.

ByXPath(string)

Returns an element using an XPath. This function supports the System.Xml XPath syntax.

Declaration

cs-api-definition
public Element ByXPath(string xpath)

Parameters

xpath

string

The XPath string. XPath is case-sensitive.

Returns

Element

The found element. The function returns null if no element is found.

ByXPath<TControl>(string)

Same as ByXPath(). Returns a control type instead of element.

Declaration

cs-api-definition
public TControl ByXPath<TControl>(string xpath) where TControl : Control, new()

Parameters

xpath

string

The XPath string. XPath is case-sensitive.

Returns

TControl

The control object.

FromCollection(FindExpressionCollection<HtmlFindExpression>)

Finds all elements with the HtmlFindExpressions in the collection.

Declaration

cs-api-definition
public IDictionary<string, Element> FromCollection(FindExpressionCollection<HtmlFindExpression> collection)

Parameters

collection

FindExpressionCollection<HtmlFindExpression>

The HtmlFindExpressions

Returns

IDictionary<string, Element>

The elements found

Remarks

If ThrowIfNullOrEmpty is true, this function will throw if an element is not found. If ThrowIfNullOrEmpty is false, this function will not add and element that we not found.

FromExpressionsFile(string)

Finds all elements with FindExpressions defined in a file.

Declaration

cs-api-definition
public IDictionary<string, Element> FromExpressionsFile(string fileName)

Parameters

fileName

string

The filename where all the FindParams are defined.

Returns

IDictionary<string, Element>

The collection of found elements in a dictionary with the key being the key defined in the file

FromExpressionsXml(string)

Finds all elements with FindExpressions defined in the serialized xml string.

Declaration

cs-api-definition
public IDictionary<string, Element> FromExpressionsXml(string xml)

Parameters

xml

string

The xml with the expressions defined.

Returns

IDictionary<string, Element>

The collection of found elements in a dictionary with the key being the key defined in the xml

ImageMatch(Image, double, int, int, float, int)

Find area within the browser view port that looks like specified image.

Declaration

cs-api-definition
public Rectangle ImageMatch(Image image, double score, int index = 0, int timeout = 2147483647, float imageScale = 1, int searchDelay = 100)

Parameters

image

Image

The image to search for.

score

double

The minimum matching score. Value must be between 0 and 100.

index

int

The image index. This is a zero-base index.

timeout

int

Timeout in milliseconds.

imageScale

float

The original screen scaling applied when the image was taken.

searchDelay

int

Number of ms to wait before searching for element image.

Returns

Rectangle

Area (in screen coordinates) that looks like specified image. Default value (default(Rectangle)) means no area is found.

ImageMatches(Image, double, int, float, int)

Find areas within the browser view port that looks like specified image.

Declaration

cs-api-definition
public ReadOnlyCollection<Rectangle> ImageMatches(Image image, double score, int timeout = 2147483647, float imageScale = 1, int searchDelay = 100)

Parameters

image

Image

The image to search for.

score

double

The minimum matching score. Value must be between 0 and 100.

timeout

int

Timeout in milliseconds.

imageScale

float

The original screen scaling applied when the image was taken.

searchDelay

int

Number of ms to wait before searching for element image.

Returns

ReadOnlyCollection<Rectangle>

Collection of screen areas that look like specified image.

Events

ReturnedNullOrEmpty

Invoked when one of the find methods returns null or an empty list of elements.

Declaration

cs-api-definition
public event EventHandler<ReturnedNullOrEmptyEventArgs> ReturnedNullOrEmpty

Event Value

EventHandler<ReturnedNullOrEmptyEventArgs>

Extension Methods

In this article
DefinitionPropertiesAssociatedBrowserFindReferenceTypeIgnoreFindAllControlMismatchLastFindParamLastSearchLogSearchRegionSearchRootElementThrowIfNullOrEmptyMethodsAllByAttributes(params string[])AllByAttributes<TControl>(params string[])AllByContent(string)AllByContent(string, FindContentType)AllByContent<TControl>(string)AllByContent<TControl>(string, FindContentType)AllByCssSelector(string)AllByCssSelector<TControl>(string)AllByCustom(Predicate<Element>)AllByCustom<TControl>(Predicate<TControl>)AllByExpression(HtmlFindExpression)AllByExpression(params string[])AllByExpression<TControl>(HtmlFindExpression)AllByExpression<TControl>(params string[])AllByImage(Image, double, bool, Point, int, float, int)AllByTagName(string)AllByTagName<TControl>(string)AllByXPath(string)AllByXPath<TControl>(string)AllControls<TControl>()AllElements()BuildBestFitFindExpression(Element)ByAttributes(params string[])ByAttributes<TControl>(params string[])ByContent(string)ByContent(string, FindContentType)ByContent(string, FindContentType, params string[])ByContent<TControl>(string)ByContent<TControl>(string, FindContentType)ByContent<TControl>(string, FindContentType, params string[])ByCssSelector(string)ByCssSelector<TControl>(string)ByCustom(Predicate<Element>)ByCustom<TControl>(Predicate<TControl>)ByExpression(HtmlFindExpression)ByExpression(HtmlFindExpression, bool)ByExpression(params string[])ByExpression<TControl>(HtmlFindExpression)ByExpression<TControl>(params string[])ById(string)ById<TControl>(string)ByImage(Image, double, int, bool, Point, int, float, int)ByName(string)ByName<TControl>(string)ByNodeIndexPath(string)ByNodeIndexPath<TControl>(string)ByTagIndex(string, int)ByTagIndex<TControl>(string, int)ByXPath(string)ByXPath<TControl>(string)FromCollection(FindExpressionCollection<HtmlFindExpression>)FromExpressionsFile(string)FromExpressionsXml(string)ImageMatch(Image, double, int, int, float, int)ImageMatches(Image, double, int, float, int)EventsReturnedNullOrEmptyExtension Methods
Not finding the help you need?
Contact Support