Table of Contents

Interface IHtmlLocator

Namespace
Xping.Sdk.Validations.Content.Html
Assembly
Xping.Sdk.dll

Html locators represent a way to find element(s) on the html content.

public interface IHtmlLocator

Methods

Filter(FilterOptions, TextOptions?)

This method narrows existing locator according to the filter, for example filters by text.

html.GetByRole(AriaRole.Listitem)
    .Filter(new { HasText = "text in column 1" })
IHtmlLocator Filter(FilterOptions filter, TextOptions? options = null)

Parameters

filter FilterOptions

Filter filter

options TextOptions

Optional parameter for customizing the search text behavior.

Returns

IHtmlLocator

First()

Returns locator to the first matching element. Example:

html.GetByRole(AriaRole.Listitem).First().ToHaveInnerText("Some text");
IHtmlLocator First()

Returns

IHtmlLocator

Last()

Returns locator to the last matching element. Example:

html.GetByRole(AriaRole.Listitem).Last().ToHaveInnerText("Some text");
IHtmlLocator Last()

Returns

IHtmlLocator

Locate(XPathExpression)

The method finds an element matching the specified selector in the locator's subtree.

IHtmlLocator Locate(XPathExpression selector)

Parameters

selector XPathExpression

A xpath selector to use when resolving DOM element.

Returns

IHtmlLocator

Nth(int)

Returns locator to the n-th matching element. It's zero based, nth(0) selects the first element. Example:

html.GetByRole(AriaRole.Listitem).Nth(2).ToHaveInnerText("Some text");
IHtmlLocator Nth(int index)

Parameters

index int

Zero based index of the matching element.

Returns

IHtmlLocator

Exceptions

ValidationException

When the index is outside the allowable range of matching elements. The exception is reported as failure in the TestSession.