prasanna kothawade
prasanna kothawade

Reputation: 51

How to convert string from JS string format in Jmeter

I am newbie in Jmeter. I am able to capture the session id as "result.sessionToken = 'A45833C7\x2D4535\x2D49C8\x2DBB46\x2D15819383F3BB';" using "Regular Expression Extractor". However, this session Token ID in request is going in different format "A45833C7-4535-49C8-BB46-15819383F3BB". Can anyone tell me, how to convert the captured dynamic data from 1 format to other? We have "Convert" attribute in "web_reg_save_param()" function in Load runner, do we have such function in Jmeter?

OR

How can we write our own code to replace "\x2D" with "-"?

Upvotes: 0

Views: 1354

Answers (1)

Dmitri T
Dmitri T

Reputation: 168197

Assuming that you have ID variable with the value of A45833C7\x2D4535\x2D49C8\x2DBB46\x2D15819383F3BB

You can replace \x2 with - Using __javaScript() function as follows:

Just replace

${__javaScript("${ID}".split('\x2').join('-'),)}

Replace and store result into ID variable

${__javaScript("${ID}".split('\x2').join('-'),ID)}

Replace and store result into FOO variable

${__javaScript("${ID}".split('\x2').join('-'),FOO)} 

For more information on using JMeter Functions see How to Use JMeter Functions post series

Upvotes: 1

Related Questions