HomeSUPPORT QUESTIONS

Need help with StresStimulus? Start here.

How to use a random extractor as a parameter Messages in this topic - RSS

Unregistered User
Unregistered User
Posts: 514


10/28/2022
Unregistered User
Unregistered User
Posts: 514
Using multiple extractors randomly.
In a particular request , 4 IDs are extracted from 4 responses (id1, id2, id3, id4).

Would like to know if id1,id2,id3 and id4 can be used in random order in subsequent request. (i.e., id1 during 1st iteration, id2 during 2nd iteration and so on)


0 link
George @StresStimulus
George @StresStimulus
Administrator
Posts: 567


10/28/2022
George @StresStimulus
George @StresStimulus
Administrator
Posts: 567
It sounds like you are creating 4 different extractors, with 4 different names, and then trying to pick one at random and use as a parameter. If this is the case, you will need to create a scriptable variable (described https://support.stresstimulus.com/display/doc54/Scriptable+Variables) and then use it to parameterize the request. Here are the steps:

/// <summary>
/// Return a value for the given session context.
/// </summary>
/// <param name="session">The session context object of the request consuming the variable.</param>
/// <returns>The source variable value.</returns>
string IExternalVariable.GetValue(SessionContext context)
{
var rnd = new Random();

return
context.ExtractorRuntime.GetExtractorValue("id" + rnd.Next(1, 5));
}
0 link






Copyright © 2024 Stimulus Technology