Boka
Boka

Reputation: 347

Dynamically change value which is read from CSV in JMeter

I have the following encoded text (part of it)

setCookie%09http%3A%2F%2Fstaging.local%3A82%2Fweb%2F%09%20SessionId%.........

I'm reading it from a CSV file and the staging.local part as well as the port 82 and possibly more values will change in the future. Is there a way to dynamically change those while reading them to ${serverName} and ${portNumber} for example which are variables that I have defined to replace the hard coded one's from the CSV?

Upvotes: 1

Views: 820

Answers (2)

Boka
Boka

Reputation: 347

I just found the way to to this, the CSV file string looks like this after the changes:

setCookie%09http%3A%2F%2F${ServerName}%3A${PortNumber}%2Fweb%2F%09%20SessionId%.........

And the way to call that string and change the values to my already defined ${ServerName} and ${PortNumber} (in JMeter User Defined Variables) is by calling ${__eval(${script})} where ${script} is the string above which I read from the CSV.

Upvotes: 2

Kaushlendra Jha
Kaushlendra Jha

Reputation: 396

I am not sure what is your exact requirement but if you want to handle the Server Name and Port Number dynamically than open Jmeter.property file (lives in bin folder of Jmeter) and define 2 variables inside it

ServerName=staging.local

PortNumber=82

Now save it and open jmeter GUI (make sure you have closed all instances of Jmeter before saving in to file). Now add property display under workbench and you will find both variables inside that. Now you can use these variables as ${__P(ServerName)} and ${__P(PortNumber)}, whereever you want to use. Suppose in future there is requirement of changing the srver name and port, you can update in property file for permanently updation or directly in property display of Jmeter (but this will remain temporary till the time your GUI is open)

Upvotes: 0

Related Questions