1. SPEForums need your contributions to build up a strong repository of performance engineering resources.

    Dismiss Notice
Dismiss Notice
Hello Guest,

Please reach out to us at anmldubey@gmail.com in case you face any issues with SPEForums. Share your feedback - Click Here

Please support us by sharing performance engineering tutorials/resources with SPEForums.com

-Crew

flexible variable

Discussion in 'Apache JMeter' started by Vitalie, Nov 18, 2018.

  1. Vitalie

    Vitalie New Member

    Joined:
    Nov 18, 2018
    Messages:
    1
    Likes Received:
    0
    Hello,
    I am a beginner in performance testing and I have one problem, I will be grateful for your help. I have in my script some variables (var1, var2, var3, ..) and i need to get in the Beanshell variables in form var "i" (for example if i = 2 get ("var2) if i = 4 get("var4" ))
    how can i do it?
    Thank you in advance

    Best regards,
    Vitalie
     
  2. Rishi sharma

    Rishi sharma New Member

    Joined:
    May 3, 2019
    Messages:
    4
    Likes Received:
    0
    int var1 = 1;
    int var2 = 2;
    int var3 = 3;

    for(int i=1;i<=3;i++)
    {
    if(i==1)
    {
    print("The value of variable is :" + var1 + "The value of i is:"+i );
    vars.put("variable1",String.valueOf(var1));
    }
    else if(i==2)
    {
    print("The value of variable is :" + var2 + "The value of i is:"+i );
    vars.put("variable2",String.valueOf(var2));
    }
    else if(i==2)
    {
    print("The value of variable is :" + var3 + "The value of i is:"+i );
    vars.put("variable3",String.valueOf(var3));
    }
    }
     
  3. Rishi sharma

    Rishi sharma New Member

    Joined:
    May 3, 2019
    Messages:
    4
    Likes Received:
    0
    Please check attached beanshell script file.
     

    Attached Files:

Share This Page