HomeSUPPORT QUESTIONS

Need help with StresStimulus? Start here.

How to get the loop number Messages in this topic - RSS

Unregistered User
Unregistered User
Posts: 514


2/10/2024
Unregistered User
Unregistered User
Posts: 514
We have a Loop in our test that runs 3 times
We want the 2nd and 3rd execution to be slightly different than the 1st:
1st time: Do all the steps
2nd time: Skip some steps
3rd time: Skip some steps

Is there a variable to tell us if the loop is at execution number 1 or 2 or 3?
We’re trying an If-Then logic, but we don’t know if there’s a variable to use in the Left Expression.
0 link
George @StresStimulus
George @StresStimulus
Administrator
Posts: 566


2/10/2024
George @StresStimulus
George @StresStimulus
Administrator
Posts: 566
This can be accomplished by creating a simple scriptable variable that is described https://support.stresstimulus.com/display/doc58/Scriptable+Variables
Here are the steps:
1. 1. Create a new scriptable variable.
a. Click the Create a variable using C# button
b. Enter the variable name “GetLoopIndex”
c. Check the On every use radio
d. Click OK





1. 2. Inside the IExternalVariable.GetValue method paste the following code: return context.LoopIndex.ToString();
2. 3. Press the Compile button in the toolbar





1. 4. In the If-Then object, set the Left Expression to {{GetLoopIndex}} or select it from the Scriptable Vars dropdown.
1.
0 link






Copyright © 2024 Stimulus Technology