It is very common to come across web pages with multiple repeating elements in the form of a list or a set of similar items. For example, you may have a "select" button against each flight option in the flight listing page on a travel portal. In this scenario, multiple "select" buttons have similar functional purpose. Also the number of such buttons is variable based on test data or time of test execution.
Your test logic will probably require you to select one of the flights and move on from this page. When setting up identification criterion, we need to be able to mark the "select" button as a "repeat" element and try not to find unique identification criterion.
Example
Consider the example below. Car Rental results are displayed. Every time you search for a car rental, you may get different options. "Pay Now" button is a Repeat element, as it could occur any number of times and all such buttons are functionally equivalent.
Selector should not show unique match
When you try to add this element to the Repository in accelQ, make sure to select only such attributes, so as to generically identify this class of element. Match count should not be unique. Compare and see if the match count looks to be the same as the number of these elements actually displayed on the application screen.
Notice that the element selector is set to result in multiple matches (21 in this case).
Repeat Element Index Policy
Once you mark an element as a Repeat element, you have a choice to select which instance number of this element you are specifically interested. You can choose from one of the policies below (while saving the element) or you can even update this index in your action logic.
- Random
- First
- Last
- n-th from first
- n-th from last
Updating repeat element instance in test logic
When you define an element as Repeat element, logic editor provides an ability to update the properties so that it points to a specific instance. In the element explorer, you may have chosen a specific or random ordinal index while defining the element. This can be changed during the logic building in the Action.
This can be done using one of the commands below
Set Repeat Element by Ordinal Index
Updates the repeat element to point to an element instance at given ordinal index.
Set Repeat Element by Text
Updates the repeat element to point to an element instance which contains given text. You may specify a regular expression pattern instead of a literal text, if required.
Set Repeat Element by Property
Updates the repeat element to point to an element instance which satisfies the given property/value combination.
It is common to build such logic for dealing with dynamic elements. At the time of setting up element selector, some of the dynamic criterion is not known and hence these commands provide the flexibility to choose exact criterion at the time of test execution.
Comments
0 comments
Please sign in to leave a comment.