TestProject Forum
Powered by leading experts in the test automation community

Iteration in TestProject

Hi

I am new in TestProject Automation (website). I would like to know how we can use iteration in TestProject. Applied a filter, and more than five search results are displayed based on the search keyword, How we can loop through each list and verify the results are listed based on the search criteria.

Hello @steffi.jose.

Iteration in the recorder is possible, see short example of how to create an iterator:

Create a test that adds 1 to an input value.

Do the action you wanted to do on the list then using the parameter you have increased before.

Add the increased value to a test parameter output value.

These parameters, like I mentioned, should be input/output parameters and not regular parameters.

Create a different test that calls the test that uses the one you made before that increases the number and performs the list action.
Create a test parameter in it that will be your starting value, I have set it to 1 in this example, then call that test using that value as both the input and output parameter.
This should iterate the list and perform the action multiple times, I have set this test to repeat 10 times:

To use this method on elements, you will need to use that increased index inside the element locator by editing it and adding the parameter into it.

So for example, after you filter the list, if all the elements, can be located using a locator with an index, such as:
(//tagname[@attribute=‘value’])[1] or [2] etc, you could incorporate the index you increment instead and search for (//tagname[@attribute=‘value’])[MY_INDEX] and the actions like ‘Get Text’ and it’s associated validations will be performed on the element located using the index.

For something more complex, I would suggest going into coding using the SDK, as this method will not work in cases where the amount of filter results is dynamic or in case they cannot be located using a locator with an index.