Some test configurations require that you can retrieve multiple elements of the same type with a single locator. There are several reasons for this:
Count the elements
It is useful to be able to count all elements of a given type to make sure without going into the details that a page, a table, a list, a search has the right number of elements.
We will take the example of a table that displays the main browsers and their porting on different operating system:
We will make a first check that verifies that the number of lines is equal to 8.
We will start by selecting a line, with an attribute that allows us to identify it, and we make sure to also identify one of his parents common to all the elements wi want to count in a unique way (starting with this one).
Then we drag-drop the element following our script to make an occurrence check equal to 8.
Obviously, the first attempt to launch the test on the fly will fail, since this element is uniquely recognized with its xid = tr5, and thus Agilitest only finds one line occurrence.
We then remove the attribute TR xid = tr5 from the locator
We obtain a non-exclusive locator which allows to find all the occurrences of TR under the element TABLE table-main
When performing the action on the fly, we confirm that Agilitest finds 8 rows in this table.
If you click on the magnifying glass:
Agilitest displays all the elements that correspond to the locator used, as well as their order number of appearance in the structure of the tested software.
Search an item by its index
When we have locators that make it possible to find several elements, it is possible to specify by an index which we wish to address.
You must click in the editor on the item that is multiple
Then to the right of the element, you will see a # and two up / down controls that identify by an index the element defined by your locator.
By validating, Agilitest allows you to retrieve specific attributes of an element identified by its index. For example, we retrieve the text in the third line of the table below.
To go further
You can use the indexes on several elements of the same locator.
This can allow you for example to go check the contents of a specific cell of a table.
This feature of identifying an element by its index can also allow you in some cases to get out of complex situations, if you lack attributes to uniquely select an item in a page.
You can also bring more robustness to your tests, for example if you often change your test data, to not select an item by its content but by its index may be more effective in the long run, but your test will be less deterministic.