Kumar
Kumar

Reputation: 443

How to access CSV config data set values in JSR223 PreProcessor

I have set up a CSV DataSet Config in a Test plan which contains UserName and Password UserName,Password Anil,Test@123 Sunil,Test@123

How can I access these variables in JSR223 preprocessor ?

Upvotes: 0

Views: 1610

Answers (1)

Dmitri T
Dmitri T

Reputation: 168072

  1. Use vars shorthand for JMeterVariables class instance like:

     def username = vars.get('UserName')
     def password = vars.get('Password`)
    

    See Top 8 JMeter Java Classes You Should Be Using with Groovy article for more details on this and other JMeter API shorthands available for JSR223 Test Elements

  2. Pass the variables via Parameters section and access them as args[0] and args[1]

    enter image description here

Demo:

enter image description here

Upvotes: 1

Related Questions