How can I get the iteration number in a loop?
Tags:
Question ID: 301
0
0

I have a repeater with a fixed count.  Is there a way to know which iteration is currently executing from within the test?

Marked as spam
Posted by (Questions: 5, Answers: 4)
Asked on May 31, 2023 7:25 am
18 views

Answers (2)

1
Private answer

Sure!

First, it is important to understand Output Variables.  Any Action has the ability to provide one or more Output Variables.  If you open an Action, you can see the Output Variables in the Action tree.

Paired with Output Variables defined in the Action is the Output Name of the test Step.  Output Variable are only populated on Steps when an Output name has been specified.

 

For the Repeat keyword example, lets use MY_REPEAT as the Output Name.  While the function defined by your Repeat step is executing, a context variable name MY_REPEAT_index will be populated with the current ZERO based index of the current iteration

 

AJ

 

Marked as spam
Posted by (Questions: 0, Answers: 5)
Answered on May 31, 2023 8:45 am
0
For a given step how do I know what the output will be? I see the "Output Name", but there is no indication that it is the iteration index. Obviously it would be different for other types of actions. Is that documented somewhere?
( at May 31, 2023 8:55 am)
0
Private answer

It is also important to mention the Data Toolbox in the IDE.  You can drag context variables ( as well as data, secrets, and environment variables) into a test to save time.  However, Context Variables will ONLY be available after a step with an Output Name has been executed at least once.  Just something to remember...

 

cm

Marked as spam
Posted by (Questions: 0, Answers: 38)
Answered on May 31, 2023 8:49 am

Welcome to Alchemy Center!
Please Log In to participate in the discussion.

X
Scroll to Top