Search code examples
jmeterbeanshell

How to put value of User Defined Variable into Bean shell Sampler Variable - Jmeter


I try to move a User Defined variable to variable in beanshell sampler. (I need the User defined variable to be part of a bigger string.)

When I try to move it, or make a copy of it I get error 500

can someone please advise how can I put the value of user defined field in bean-shell variable and than use it (not need to change the user defined variable just want it value)

In this script I Want to put the value of $Expected_Offer_ID to String variable Expected_Offer

enter image description here

enter image description here


Solution

  • There are (at least) 2 options:

    1. Put ${Expected_Offer_ID} to "Parameter" section of the Sampler. You will be able to access it as Parameters in your script
    2. Use vars.get("Expected_Offer_ID); where required. vars is a shorthand to JMeterVariables class instance, it provides read/write access to all JMeter Variables

    JMeter Groovy Access Variables

    Remember 2 things: