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
FilterOptionsFilter filter
options
TextOptionsOptional parameter for customizing the search text behavior.
Returns
First()
Returns locator to the first matching element. Example:
html.GetByRole(AriaRole.Listitem).First().ToHaveInnerText("Some text");
IHtmlLocator First()
Returns
Last()
Returns locator to the last matching element. Example:
html.GetByRole(AriaRole.Listitem).Last().ToHaveInnerText("Some text");
IHtmlLocator Last()
Returns
Locate(XPathExpression)
The method finds an element matching the specified selector in the locator's subtree.
IHtmlLocator Locate(XPathExpression selector)
Parameters
selector
XPathExpressionA xpath selector to use when resolving DOM element.
Returns
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
intZero based index of the matching element.
Returns
Exceptions
- ValidationException
When the index is outside the allowable range of matching elements. The exception is reported as failure in the TestSession.