public interface WebElements extends List<WebElement>
Represents a collection of elements on a page. The existence of a WebElements instance does not state that the underlying elements exists on the page. It just stores the search criteria and another information about the elements. Later, when the WebElement instances are going to be used, will be verified that the underlying elements exist or not. Therefore it is safe to store a WebElements instance and use it later.
A WebElements instance does not have direct methods to manipulate the element itself or
do some assertions with it - these are available from page objects. (See PageObject.)
During element manipulation and verification the ibello reruns the search again
if necessary. A typical example is when an element on a page is recreated by javascript code
after the search. In this case, the original element is not present anymore so it can't be clicked.
If someone tries to call a click action on it, then ibello recognizes the change and executes
the search again. Only if the second search does not finds anything will ibello throw an
exception.
The WebElements interface extends the List interface (with WebElement items).
Unlike "normal" lists, a WebElements instance never throws exception when someone reads a non-existing item
- see List.get(int). Instead of it, a new WebElement instance is created and returned (which
points to a non-existing element). Therefore it is safe to call List.get(int) on a WebElements
instance then check the existence of the element returned.
If a WebElements instance was obtained by a search which received parameters, then there is an option to
change these parameters later, and rerun the search - see applyParameters(Object...).
WebElement| Modifier and Type | Method and Description |
|---|---|
WebElements |
applyParameters(Object... parameters)
Changes the search parameters of this WebElements instance.
|
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArrayparallelStream, removeIf, streamWebElements applyParameters(Object... parameters)
Changes the search parameters of this WebElements instance.
A WebElements instance can be created with an element search - see SearchTool and
PageObject. During the search
some parameters can be specified, which are substituted into the search pattern. The WebElements instance
stores these parameters, and we can change them to indicate a new search later, when the instance is going
to be used.
It is possible to not define the parameters at the time of the creation of a WebElements instance, and set them later, before the instance is used. Example (from a page object):
// search elements without specifying the parameter
@Find("#row-${0} .cell")
WebElements cells;
public expectCellIsVisible(int rowIndex, int columnIndex) {
// set the parameter and therefore rerun the search
// before we perform assertion
expect().that(cells.applyParameters(rowIndex).get(columnIndex)).isVisible();
}
parameters - the new search parametersCreated by Kornél Simon, 2022