public interface SearchTool
Interface for searching elements on a page. It offers a fluent interface for element search. Examples:
Search a single element:
SearchTool find = ...;
WebElement element = find.using(By.LABEL, "Field #${0}:", 1).first();
Search multiple elements (below a specific one):
WebElement currentRow = ...; SearchTool find = ...; WebElements element = find.using(By.TAG_NAME, "tr").below(currentRow).all();
About ibello search engine see hu.ibello.search.
| Modifier and Type | Method and Description |
|---|---|
SearchTool |
above(WebElement anchor)
Modifies the element search so the desired element should be above the anchor element.
|
WebElements |
all()
Get all elements on the page that match the conditions.
|
SearchTool |
asAncestorOf(By by,
String pattern,
Object... parameters)
Modifies the element search so the desired element should be the ancestor of the anchor element.
|
default SearchTool |
asAncestorOf(String pattern,
Object... parameters)
Modifies the element search so the desired element should be the ancestor of the anchor element.
|
SearchTool |
below(WebElement anchor)
Modifies the element search so the desired element should be below the anchor element.
|
WebElement |
first()
Get only the first element on the page which matches the conditions.
|
SearchTool |
inColumnOf(WebElement anchor)
Modifies the element search so the desired element should be in the same column as the anchor element.
|
SearchTool |
inRowOf(WebElement anchor)
Modifies the element search so the desired element should be in the same row as the anchor element.
|
SearchTool |
leftFrom(WebElement anchor)
Modifies the element search so the desired element should be left from the anchor element.
|
SearchTool |
nearestTo(WebElement anchor)
Modifies the element search to capture the nearest elements to the given anchor element.
|
default WebElement |
nth(int index)
Get the nth element on the page which matches the conditions.
|
SearchTool |
rightFrom(WebElement anchor)
Modifies the element search so the desired element should be right from the anchor element.
|
SearchTool |
using(By by,
String pattern,
Object... parameters)
Sets the main search conditions for the element search.
|
default SearchTool |
using(String pattern,
Object... parameters)
Sets the main search conditions for the element search.
|
SearchTool using(By by, String pattern, Object... parameters)
Sets the main search conditions for the element search.
The by argument specifies the main search algorithm. It is an enum constant of By.
The meaning of pattern argument depends on the value of by. For more information,
see enum constants of By.
The parameters is a vararg. It specifies parameters in the pattern argument.
If pattern contain parameter substitution markers then the method will substitute
the parameters into those places. A parameter substitution marker is a 0-based index surrounded by
${ and }. For example, if pattern is "${0}-${1}",
then the method will replace ${0} with the first parameter, and ${1}
with the second parameter. If the parameters are "a" and 1, then the
result pattern will be "a-1".
by - search algorithmpattern - search patternparameters - substitute parameters of patternSearchTool instanceFinddefault SearchTool using(String pattern, Object... parameters)
Sets the main search conditions for the element search.
The search algorithm of the anchor is By.CSS_SELECTOR. The pattern argument
should be a CSS selector.
The parameters is a vararg. It specifies parameters in the pattern argument.
If pattern contain parameter substitution markers then the method will substitute
the parameters into those places. A parameter substitution marker is a 0-based index surrounded by
${ and }. For example, if pattern is "#${0}-${1}",
then the method will replace ${0} with the first parameter, and ${1}
with the second parameter. If the parameters are "a" and 1, then the
result pattern will be "#a-1".
pattern - search patternparameters - substitute parameters of patternSearchTool instanceusing(By, String, Object...),
FindSearchTool inRowOf(WebElement anchor)
anchor - another element on the pageSearchTool instancePosition,
PositionType.ROWSearchTool inColumnOf(WebElement anchor)
anchor - another element on the pageSearchTool instancePosition,
PositionType.COLUMNSearchTool leftFrom(WebElement anchor)
anchor - another element on the pageSearchTool instancePosition,
PositionType.LEFT_FROMSearchTool rightFrom(WebElement anchor)
anchor - another element on the pageSearchTool instancePosition,
PositionType.RIGHT_FROMSearchTool above(WebElement anchor)
anchor - another element on the pageSearchTool instancePosition,
PositionType.ABOVESearchTool below(WebElement anchor)
anchor - another element on the pageSearchTool instancePosition,
PositionType.BELOWSearchTool asAncestorOf(By by, String pattern, Object... parameters)
The by argument specifies the search algorithm. It is an enum constant of By.
The meaning of pattern argument depends on the value of by. For more information,
see enum constants of By.
The parameters is a vararg. It specifies parameters in the pattern argument.
If pattern contain parameter substitution markers then the method will substitute
the parameters into those places. A parameter substitution marker is a 0-based index surrounded by
${ and }. For example, if pattern is "${0}-${1}",
then the method will replace ${0} with the first parameter, and ${1}
with the second parameter. If the parameters are "a" and 1, then the
result pattern will be "a-1".
by - search algorithm of anchor elementpattern - search pattern of anchor elementparameters - search parameters of anchor elementSearchTool instanceRelation,
RelationType.ANCESTOR_OFdefault SearchTool asAncestorOf(String pattern, Object... parameters)
The search algorithm of the anchor is By.CSS_SELECTOR. The pattern argument
should be a CSS selector.
The parameters is a vararg. It specifies parameters in the pattern argument.
If pattern contain parameter substitution markers then the method will substitute
the parameters into those places. A parameter substitution marker is a 0-based index surrounded by
${ and }. For example, if pattern is "#${0}-${1}",
then the method will replace ${0} with the first parameter, and ${1}
with the second parameter. If the parameters are "a" and 1, then the
result pattern will be "#a-1".
pattern - search pattern of anchor elementparameters - search parameters of anchor elementSearchTool instanceRelation,
RelationType.ANCESTOR_OFSearchTool nearestTo(WebElement anchor)
anchor - another element on the pageSearchTool instanceWebElement first()
Get only the first element on the page which matches the conditions.
This method always returns a non-null object, even if the element is not present on the
page at the time of the search. The returned WebElement instance can be used for
different actions and assertions later - there is no need to search with the same arguments
again.
default WebElement nth(int index)
Get the nth element on the page which matches the conditions. The index of the element should be specified with the parameter. It is 0-based, so the index of the first element is 0, the second is 1, and so on.
This method always returns a non-null object, even if the element is not present on the
page at the time of the search. The returned WebElement instance can be used for
different actions and assertions later - there is no need to search with the same arguments
again.
index - 0-based index of the elementWebElements all()
Get all elements on the page that match the conditions.
This method always returns a non-null object, even if the elements are not present on the
page at the time of the search. The returned WebElements instance can be used for
different actions and assertions later - there is no need to search with the same arguments
again.
Created by Kornél Simon, 2022